TransWikia.com

Airplane mode gets turned on and stuck after sleep mode

Ask Ubuntu Asked by thundr_strike on September 20, 2020

I am using Ubuntu 18.04 LTS dual booted with Windows 7 on HP Envy 15. After my laptop goes into sleep mode (lid closed) it will turn on airplane mode but the button to turn it off is greyed out and says "use hardware switch to turn off" and the only other switch is the Fn+F12 which doesn’t work. It fixes itself on reboot but I was wondering if there was a way to prevent it. In Windows, it happens plugged in and on battery.
Before sleep:

$ sudo rfkill
ID TYPE      DEVICE      SOFT      HARD
 0 bluetooth hci0   unblocked unblocked
 1 wlan      phy0   unblocked unblocked

After sleep:

$ sudo rfkill
ID TYPE      DEVICE      SOFT      HARD
 1 wlan      phy0   unblocked   blocked

I have tried blocking and unblocking it via rfkill but it doesn’t work the only way that I have found to disable it is via rebooting.

One Answer

After sleep try to execute the next:

sudo systemctl restart network-manager.service 
sudo ifconfig wlx8c882b131d8 up
sudo rfkill unblock all

Change wlx8c882b131d8 to your own wi-fi adapter interface name. If this works, than you could create a systemd service that will start just after resume from sleep and do it automatically for you.

Also, in some cases, battery removing/inserting works.

And also, does your keys combination that enables/disables your wi-fi works in case of using it on unblocked device? If no, than find out, why the shortcut keys combination does not work.

And, as nobody suggested (reference)

gsettings list-recursively | less

You'll find the entry about Airplane Mode by typing /rfkill. Copy that line and use it on a new command line with the gsettings "set" parameter, but change the "true" to "false":

gsettings set org.gnome.settings-daemon.plugins.rfkill active false

But previous suggested command has its own cons. So you could try the next suggested solution taken from the same reference:

I had the same problem on my HP 250 G5. For me it was caused by the lid sending scancodes e058/e057 on lid close/open.

For some reason GNOME decided this corresponded to Airplane Mode On. As ropid mentioned you can fix it by disabling GNOME's rfkill plugin, but this also prevents enabling/disabling bluetooth via GNOME settings.

I managed to fix this on my by mapping e058/e057 to keycode 245 (Display Off)

Use { journalctl -f } before closing and opening your lid to find out if closing the lid simulates any key presses. The journal entry should also tell you the scan code of the key press (e058 & e057 in my case)

Then use { setkeycodes [SCANCODE] [KEYCODE] } to map the scancode sent by the lid to a desired key (in my case I used setkeycodes e058 245 e057 245). If you don't want to map it to DISPLAY OFF you can find a list of other keycodes in /usr/include/linux/input-event-codes.h

If the problem is fixed make it persistent by creating and enabling a systemd unit file in /etc/systemd/system/ The file I use looks like this:

[Unit]
Description=Fix WiFi off on lid close

[Service]
ExecStart=/usr/bin/setkeycodes e058 245 e057 245

[Install]
WantedBy=multi-user.target

Answered by Gryu on September 20, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP