If you are like me and struggle that the suspend function when closing the lid on your
~> inxi -M
Machine:
Type: Convertible System: HP product: HP ENVY x360 Convertible 15-ed0xxx
v: Type1ProductConfigId serial: <superuser required>
Mobo: HP model: 8757 v: 08.42 serial: <superuser required> Firmware: UEFI
vendor: Insyde v: F.24 date: 03/16/2022
HP notebook does not work, there are several fixes and tweaks to the system that can be tried. I have literally tried all of them, and believe me, they all DO NOT WORK.
What is the problem? The suspend function in linux works ok, because
# systemctl suspend
works flawlessly. But it does not work when setting the events in KDE plasma Power Management settings. Believe me, it simply does not work.
Then I tried a LOT of other options, ranging from GRUB kernel boot options to creating custom ACPI events and letting systemd logind handle the event etc. etc. etc.
I spend a lot of time, none of the options worked for me. Finally this solution worked. it uses a service to manually suspend the machine (since the command does work normally).
Here are the 3 things you have to do:
1. Create a unit file
Create a unit file :
# vi /etc/systemd/system/lid-suspend.service
with the following content:
[Unit]
Description=HP Envy lid close suspend poller
After=plasma-kwin_wayland.service powerdevil.service
Wants=plasma-kwin_wayland.service powerdevil.service
[Service]
Type=simple
ExecStartPre=
ExecStart=/usr/local/bin/lid-suspend.sh
Restart=always
RestartSec=5
CPUWeight=1
IOSchedulingClass=idle
[Install]
WantedBy=default.target
2. create a script
Create the following script:
# vi /usr/local/bin/lid-suspend.sh
with the following content:
#!/bin/bash
exec > /var/log/lid-suspend.log 2>&1
echo "$(date): Lid poller v2 started - checking all paths"
while true; do
for path in /proc/acpi/button/lid/LID*/state /proc/acpi/button/lid/state /sys/class/input/*/uevent; do
if [ -f "$path" ]; then
if grep -qi "closed\|LID=closed" "$path" 2>/dev/null; then
echo "$(date): Lid closed op $path - suspending!"
systemctl suspend
sleep 15
break 2
fi
fi
done
# Fallback: input event checken
if ls /sys/class/input/input*/name 2>/dev/null | grep -qi lid; then
echo "$(date): Lid input device gevonden via fallback"
fi
sleep 1
done
3. activate the files
# chmod +x /usr/local/bin/lid-suspend.sh
# systemctl daemon-reload
# systemctl enable --now lid-suspend.service
After this, the suspend function works when the lid is closed in linux plasma6!
