[Solved] start in airplane mode [solved]

Message
Author
fan_of_LTS
Posts: 101
Joined: Sat Jun 13, 2020 11:49 am

[Solved] start in airplane mode [solved]

#1 Post by fan_of_LTS »

I use a script to start in airplane mode when I login. I frequently suspend to ram and sometimes forget to disconnect wifi and disconnect the radio first. The script will temporarily go into airplane mode upon suspend BUT the autostart saves your state when resuming from suspend and if I was connected, it reconnects. This even though I do have the script run on login and on suspend.

Anyone know how I can keep from reconnecting upon resuming from suspend? I'd like to set my laptop to always start in airplane mode and resume in airplane mode even if I was connected when suspending.

Thanks for any pointers. I am sure I am missing something obvious here. :confused:

(just edited to show solved)
Last edited by fan_of_LTS on Mon Aug 10, 2020 5:08 pm, edited 1 time in total.

User avatar
JayM
Posts: 6796
Joined: Tue Jan 08, 2019 3:47 am

Re: start in airplane mode

#2 Post by JayM »

Please provide your Quick System Info as per my signature (the link explains how to properly add it to posts) and also the contents of your script pasted between [code] [/code] tags by clicking the </> icon in the post editor prior to pasting. Don't forget to preview your post to make sure your QSI and script aren't posted as normal text, as per the HOWTO linked to in my signature. One more thing, can you run your script in a terminal and post any error messages you may get? Thanks.
Please read the Forum Rules, How To Ask For Help, How to Break Your System and Don't Break Debian. Always include your full Quick System Info (QSI) with each and every new help request.

fan_of_LTS
Posts: 101
Joined: Sat Jun 13, 2020 11:49 am

Re: start in airplane mode

#3 Post by fan_of_LTS »

Thanks for your attention. QSI, feeble attempt at an airplane mode script, and results from running in a terminal follow.

Quick system info

Code: Select all

System:    Host: <filter> Kernel: 4.19.0-6-amd64 x86_64 bits: 64 compiler: gcc v: 8.3.0 
           parameters: BOOT_IMAGE=/vmlinuz-4.19.0-6-amd64 
           root=UUID=4fec771d-d6b6-4b9f-9f66-69796ca779db ro quiet splash 
           Desktop: Xfce 4.14.2 tk: Gtk 3.24.5 info: xfce4-panel wm: xfwm4 dm: LightDM 1.26.0 
           Distro: MX-19.2_x64 LTS released October 21  2019 base: Debian GNU/Linux 10 (buster) 
Machine:   Type: Convertible System: HP product: HP ENVY x360 Convertible 15-cp0xxx v: N/A 
           serial: <filter> Chassis: type: 31 serial: <filter> 
           Mobo: HP model: 8497 v: 92.46 serial: <filter> UEFI [Legacy]: AMI v: F.42 
           date: 05/13/2019 
Battery:   ID-1: BAT0 charge: 55.3 Wh condition: 55.3/55.3 Wh (100%) volts: 12.9/11.6 
           model: 333-54-35-A LK03052XL type: Li-ion serial: <filter> status: Full 
           Device-1: hid-0018:04F3:2650.0001-battery model: ELAN0732:00 04F3:2650 serial: N/A 
           charge: N/A status: N/A 
CPU:       Topology: Quad Core model: AMD Ryzen 5 2500U with Radeon Vega Mobile Gfx bits: 64 
           type: MT MCP arch: Zen family: 17 (23) model-id: 11 (17) stepping: N/A 
           microcode: 810100B L2 cache: 2048 KiB 
           flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm bogomips: 31938 
           Speed: 1464 MHz min/max: 1600/2000 MHz boost: enabled Core speeds (MHz): 1: 1464 
           2: 1461 3: 2294 4: 1973 5: 1818 6: 1799 7: 2397 8: 1772 
           Vulnerabilities: Type: itlb_multihit status: Not affected 
           Type: l1tf status: Not affected 
           Type: mds status: Not affected 
           Type: meltdown status: Not affected 
           Type: spec_store_bypass 
           mitigation: Speculative Store Bypass disabled via prctl and seccomp 
           Type: spectre_v1 mitigation: usercopy/swapgs barriers and __user pointer sanitization 
           Type: spectre_v2 
           mitigation: Full AMD retpoline, IBPB: conditional, STIBP: disabled, RSB filling 
           Type: tsx_async_abort status: Not affected 
Graphics:  Device-1: AMD Raven Ridge [Radeon Vega Series / Radeon Vega Mobile Series] 
           vendor: Hewlett-Packard driver: amdgpu v: kernel bus ID: 04:00.0 chip ID: 1002:15dd 
           Display: x11 server: X.Org 1.20.4 driver: amdgpu,ati unloaded: fbdev,modesetting,vesa 
           resolution: 1920x1080~60Hz 
           OpenGL: renderer: AMD RAVEN (DRM 3.27.0 4.19.0-6-amd64 LLVM 10.0.0) 
           v: 4.6 Mesa 20.0.7 direct render: Yes 
Audio:     Device-1: AMD Raven/Raven2/Fenghuang HDMI/DP Audio vendor: Hewlett-Packard 
           driver: snd_hda_intel v: kernel bus ID: 04:00.1 chip ID: 1002:15de 
           Device-2: AMD Raven/Raven2/FireFlight/Renoir Audio Processor vendor: Hewlett-Packard 
           driver: N/A bus ID: 04:00.5 chip ID: 1022:15e2 
           Device-3: AMD Family 17h HD Audio vendor: Hewlett-Packard driver: snd_hda_intel 
           v: kernel bus ID: 04:00.6 chip ID: 1022:15e3 
           Sound Server: ALSA v: k4.19.0-6-amd64 
Network:   Device-1: Realtek RTL8822BE 802.11a/b/g/n/ac WiFi adapter vendor: Hewlett-Packard 
           driver: r8822be v: kernel port: f000 bus ID: 03:00.0 chip ID: 10ec:b822 
           IF: wlan0 state: up mac: <filter> 
Drives:    Local Storage: total: 303.53 GiB used: 10.91 GiB (3.6%) 
           ID-1: /dev/mmcblk0 model: SA08G size: 7.21 GiB block size: physical: 512 B 
           logical: 512 B serial: <filter> scheme: MBR 
           ID-2: /dev/nvme0n1 vendor: Samsung model: MZVLB256HAHQ-000H1 size: 238.47 GiB 
           block size: physical: 512 B logical: 512 B speed: 31.6 Gb/s lanes: 4 serial: <filter> 
           rev: EXD70H1Q scheme: GPT 
           ID-3: /dev/sda type: USB vendor: SanDisk model: Ultra Fit size: 57.84 GiB block size: 
           physical: 512 B logical: 512 B serial: <filter> rev: 1.00 scheme: MBR 
Partition: ID-1: / raw size: 13.87 GiB size: 13.58 GiB (97.98%) used: 8.27 GiB (60.9%) fs: ext4 
           dev: /dev/dm-0 
           ID-2: /boot raw size: 1011.0 MiB size: 995.1 MiB (98.43%) used: 144.2 MiB (14.5%) 
           fs: ext4 dev: /dev/sda1 
           ID-3: /home raw size: 13.75 GiB size: 13.47 GiB (97.97%) used: 2.50 GiB (18.5%) 
           fs: ext4 dev: /dev/dm-1 
Sensors:   System Temperatures: cpu: 46.9 C mobo: 33.0 C gpu: amdgpu temp: 46 C 
           Fan Speeds (RPM): N/A 
Repos:     No active apt repos in: /etc/apt/sources.list 
           Active apt repos in: /etc/apt/sources.list.d/debian-stable-updates.list 
           1: deb https://deb.debian.org/debian buster-updates main contrib non-free
           Active apt repos in: /etc/apt/sources.list.d/debian.list 
           1: deb https://deb.debian.org/debian buster main contrib non-free
           2: deb https://deb.debian.org/debian-security buster/updates main contrib non-free
           Active apt repos in: /etc/apt/sources.list.d/mx.list 
           1: deb https://mirror.vcu.edu/pub/gnu_linux/mxlinux/mx/repo/ buster main non-free
           2: deb https://mirror.vcu.edu/pub/gnu_linux/mxlinux/mx/repo/ buster ahs
           No active apt repos in: /etc/apt/sources.list.d/various.list 
Info:      Processes: 279 Uptime: 2d 13h 42m Memory: 6.83 GiB used: 1.83 GiB (26.8%) 
           Init: SysVinit v: 2.93 runlevel: 5 default: 5 Compilers: gcc: 8.3.0 alt: 8 
           Shell: quick-system-in running in: quick-system-in inxi: 3.0.36 
airplane.sh

Code: Select all

#! /bin/bash
#  shutting down network connection
nmcli dev disconnect wlan0
nmcli radio wifi off
nmcli networking off
# turn off all radios including bluetooth
rfkill block all
exit
The only message from running in a terminal is "Device 'wlan0' successfully disconnected." and it works. I'd like it to run on suspend even if I forget (or don't have time such as just closing the lid) which it does but then suspend restores the previous state.

User avatar
jocester
Posts: 76
Joined: Sun Apr 19, 2020 3:27 am

Re: start in airplane mode

#4 Post by jocester »

instead of the script you can use tlp to disable wlan and bluethooth at startup

User avatar
eriefisher
Posts: 142
Joined: Fri Sep 07, 2007 8:11 am

Re: start in airplane mode

#5 Post by eriefisher »

#! /bin/bash
# shutting down network connection
nmcli dev disconnect wlan0
nmcli radio wifi off
nmcli networking off
# turn off all radios including bluetooth
rfkill block all
exit
That's some paranoia right there.You want disconnect, shut off the radio, kill networking totally and block all radios????? Yes I think tlp-rdw will work.

https://wiki.archlinux.org/index.php/TLP

fan_of_LTS
Posts: 101
Joined: Sat Jun 13, 2020 11:49 am

Re: start in airplane mode

#6 Post by fan_of_LTS »

jocester and eriefisher, thanks for the suggestion on tlp and tlp-rdw, longest runtime on battery is my goal and by not running the radios when not in use, I expect to be able to run longer on battery.

Both tlp and the script are effective at shutting down wireless. I currently start up without wireless and start it if that is what I want. The part I can't solve is that if I enable wireless to use email/web and then don't shut it down before suspending to RAM (as for example if I shut the lid intending to come back in a few minutes) the autorun script does shut down the radios (it also works on boot up to keep them down until needed) BUT shortly after resuming from suspend the radios restart if that was their state prior to suspend. I don't want them to start up until I tell them.

The session and startup has triggers on startup, on shutdown, on suspend, but I didn't see one for on resume. That is probably what I am thinking would be nice to have.

Normally saving state upon suspend is great. I don't know how/where all the info is stored or if it is possible to just override the radio state so the resume won't restart just the radios.

ef, it's not just paranoia ;) but trying to bend this machine to my will! Still, it's way better than Windows was!

By the way, the ahs version uses several watts less (about 15% less) according to a wattmeter I used on this machine. Maybe I will move to that later.

clicktician
Posts: 136
Joined: Sat May 02, 2015 4:35 pm

Re: start in airplane mode

#7 Post by clicktician »

fan_of_LTS wrote: Sun Aug 09, 2020 7:35 am BUT shortly after resuming from suspend the radios restart if that was their state prior to suspend. I don't want them to start up until I tell them.
If you disable WiFi and Bluetooth using the GUI interfaces immediately before you suspend, tho, the UI network mon et. al. will remember their states and not start those services up.
The problem is, they're not scriptable.... or are they?

I have a similar problem with my VPN which doesn't like to share info with the shell.
(forgive me, oh Lords of Cobol for my eye-rolling blasphemy, but...)
I just use xdotool to open the iconified tool in the system tray, and click the changes I want.
I even screen-scrape info to the clipboard and paste it into my shell for further programmatic use.

Gimp and delayed (so you can right click ahead of the camera) screenshots make it trivial to find out screen coordinates.
And for dynamically placed windows xdotool can search for them by name. Or you can use xprop or even ps to find window info.
Son, someday all this will belong to your ex wife.

User avatar
jocester
Posts: 76
Joined: Sun Apr 19, 2020 3:27 am

Re: start in airplane mode

#8 Post by jocester »

create /etc/pm/sleep.d/20-wifi-bluetooth-off
edit in this way:

Code: Select all

#!/bin/sh
wifi off && bluetooth off
this should disable wifi/bluetooth after resume

fan_of_LTS
Posts: 101
Joined: Sat Jun 13, 2020 11:49 am

[Solved} Re: start in airplane mode

#9 Post by fan_of_LTS »

Thank you! This passed the test and works exactly as I wanted!

Post Reply

Return to “Software / Configuration”