From cb1da589ca49c4351ad627503b29a72b074c3f99 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Tue, 12 Sep 2023 20:30:16 +0530 Subject: add new blog post --- content/blog/2023/hp-setkeycodes-fix.md | 67 +++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 content/blog/2023/hp-setkeycodes-fix.md (limited to 'content') diff --git a/content/blog/2023/hp-setkeycodes-fix.md b/content/blog/2023/hp-setkeycodes-fix.md new file mode 100644 index 0000000..17ca626 --- /dev/null +++ b/content/blog/2023/hp-setkeycodes-fix.md @@ -0,0 +1,67 @@ +--- +title: ACTUALLY fix WiFi turning off on laptop lid close +date: 2023-09-12 +--- + +If you have an HP laptop running linux you might have noticed that when you close the lid and open it again it turns off the WiFi. +Note that the weird part is that it turns off the WiFi after the lid *opens,* not when it's closed. + +This is really weird and annoying because I constantly close the lid and open it again in class and stuff +and sometimes I just don't wanna lose the network connection! + +I searched on the internet and found a fix using setkeycodes. + +``` +setkeycodes e057 240 e058 240 +``` + +Everywhere I searched people were using the same custom systemd service +that apparently worked for them, but not for me. The fix worked, but not the systemd service. +After checking some logs, I found this: + +``` +hp-keycodes.service: Failed to open /etc/systemd/system/hp-keycodes.service: No such file or directory +``` + +Hmm so if I did a `systemctl start hp-keycodes` it worked but not with `systemctl enable`. Weird. +It somehow couldn't find the .service file while booting up. + +## The Fix + +The is the correct systemd service that you need to use: + +Store it as `/etc/systemd/system/hp-keycodes.service`. + +``` +[Unit] +Description=HP setkeycodes fix + +[Service] +Type=oneshot +Restart=no +RemainAfterExit=no +ExecStart=/usr/bin/setkeycodes e057 240 e058 240 + +[Install] +WantedBy=multi-user.target +``` + +and just run `systemctl enable --now hp-keycodes.service`. + +Now, when you close and re-open your laptop's lid, it won't toggle the WiFi. + +*If this fix doesn't work for you, it probably means it's a different thing that's causing problems and you should research more instead of following this guide.* + +## The problem with other fixes + +On almost every website I saw the same .service file. What's different in mine is that it uses `WantedBy=multi-user.target` while the others had this: + +``` +[Install] +WantedBy=rescue.target +WantedBy=multi-user.target +WantedBy=graphical.target +``` + +I just removed `rescue.target` and `graphical.target` and it worked! + -- cgit v1.2.3