0

Using GNOME tweak tool, I have already selected off to 'Suspend when laptop lid is closed'. So, the system doesn't suspend. But, when I close the lid and reopen it, system goes in aeroplane mode and hence WiFi and bluetooth get disconnected.

I already tried this and this. But, those didn't work.

IR-x86
  • 1
  • 2

1 Answers1

2

I had the same problem. (Do you have a HP laptop?)

The next steps will test if you have the same problem as I had and also will provide solution. It is based in a very useful comment from usser "ebin92" on reddit about this topic.

TEST

We gonna check if the open/close lid event is sending scancodes and, if so, remap them

  • Open a terminal and type: <journalctl -f>
  • Then open and close the lid, and check in the terminal for an unknown scancode (in my case they were "e058" and "e057")
  • Remap the scancodes that your lid are sending to DISPLAY OFF code (you can remap it to another keycode if you want) For that, use >> setkeycodes [SCANCODE] [KEYCODE] In my case, >> setkeycodes e058 245 e057 245

Try again opening and closing your lid and if the problem is solved, lets make it permanent.

PERMANENT FIX

We are going to enable a new systemd service to remap the scancodes on boot up

  • Open a terminal and go to /etc/systemd/system. Execute next steps as superuser
  • Create a new file with name format "YOURNAME.service". In my case it was "lidbehaviour_override.service"
  • Put inside the attached content (see below) and edit the keycodes to your case
  • Give to the file execution permissions, running >> sudo chdmod a+x FILENAME In my case >> sudo chdmod a+x lidbehaviour_override.service
  • Test everything is fine running the service. For that: · reload the daemon configuration (all you have modified in systemd) with sudo systemctl daemon-reload · run the new service with sudo systemctl start YOURNAME.service In my case systemctl start lidbehaviour_override.service · Open and close the lid
  • If everything went right, then make the service starts on boot up sudo systemctl enable YOURNAME.service In my case systemctl enable lidbehaviour_override.service

SYSTEMD SERVICE CONTENT

[Unit]
Description=Fix aeroplane mode on/off when lid opens/closes

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

[Install]
WantedBy=multi-user.target
Gryu
  • 7,559
  • 9
  • 33
  • 52
Paco2L
  • 21