Closing the lid with XFCE4

22-10-22 10:06 simon

After setting up a new laptop and find the lid switch is not recognized by logind or xfce4 power manager I found the state of the lid is reported

while :; do echo -n "$(date) -- "; cat /proc/acpi/button/lid/LID0/state ; sleep 1 ; done

So adding a script to watch for this at startup makes the machine suspend when the lid is closed. I created in $HOME/bin/

while :; do
grep -q closed /proc/acpi/button/lid/LID0/state
if [ $? = 0 ]
xfce4-session-logout --suspend
sleep 5;