Wifi Turns off when opening the Lid (Activates Airplane Mode)

I have been having this problem for ages and all the other forum entries did not help with the issue, this is not a “problem post” but rather a solution to future users who may be in the same boat as I was.

Please, Try the basic solution first, which is to turn off suspend when closing the lid in tweaks. If like me that didn’t help then proceed with the solution below.


sudo journalctl -f

In the command line, and closing the lid, you may discover that an unknown button is triggered to turn on Airplane mode, by default it should be e058 and e057

If this is happening to you as well then this is your solution, we need to change that button’s action to only trigger the screen off (245)
in order to do this, type this in the command line:

sudo setkeycodes e058 245 e057 245

Test if it worked by closing the lid and opening again, if it worked then let’s make this permanent on boot by adding a systemd unit file in /etc/systemd/system/

Paste the following data into that file


Description=Fix WiFi off on lid close


ExecStart=/usr/bin/setkeycodes e058 245 e057 245




Thank you for sharing the solution with the community.

But please post the solution as a reply to your topic and then select the reply as solution like this below the answer that helped you most:
so that the next person that has the exact same problem you just had will benefit from your post as well as your question will now be in the “solved” status and people trying to help can save time looking at questions that were already solved


edit your post so that it becomes a tutorial

and take a look at some of the tutorials that already exist

Honestly speaking you are right upto an extent, but if someone is trying to provide a help or a solution for future users who might come across said problems.
I see no harm in the way he made the post as long as a person with no knowledge of anything linux could just read this and solve the problem, the post is valid.
And I as a person thank @MISAKIBeats cause this actually gave a solution to my problem.