You are not logged in.
I have a small issue (annoyance) with my laptop - if the laptop is sleeping with the lid open, and the lid is then closed, the laptop wakes up.
I'm trying to implement a dirty workaround where a bash script tests if the laptop lid is closed, and then calls systemctl suspend if it is.
In /usr/lib/systemd/system-sleep I have created onwakeup.sh:
#!/bin/bash
PATH=/sbin:/usr/sbin:/bin:/usr/bin
if [[ "${1}" == "post" ]]; then
# AFTER RESUMING FROM SLEEP
printf "`date +%T` " >> /tmp/wake.log
echo "Have resumed..." >> /tmp/wake.log
sleep 1
grep -q closed /proc/acpi/button/lid/LID0/state
if [ $? = 0 ]
then
printf "`date +%T` " >> /tmp/wake.log
echo "Have resumed and lid is closed, attempting to suspend..." >> /tmp/wake.log
systemctl suspend
fi
fi
The systemctl suspend line doesn't work though. From /tmp/wake.log:
18:39:50 Have resumed...
18:39:51 Have resumed and lid is closed, attempting to suspend...
Any idea why the systemctl suspend line in the script isn't working?
Last edited by andyturfer (2024-02-18 00:10:34)
Offline
Offline
Solved: https://bbs.archlinux.org/viewtopic.php … 5#p2151355
Looks like systemctl suspend doesn't work for scripts in /usr/lib/systemd/system-sleep. Had to use this instead:
echo freeze > /sys/power/state
Offline