Closing the lid fix

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

cat /proc/acpi/button/lid/LID0/state
So adding a script to watch for this at startup makes the machine suspend when the lid is closed. I created lidcheck.sh in $HOME/bin/

#!/bin/bash

while :; do
    grep -q closed /proc/acpi/button/lid/LID0/state
    if [ $? = 0 ] ; then
        /usr/bin/keepassxc --lock &
        swaylock &
        systemctl suspend
    fi
    sleep 5;
done



As an update, this never changed, various DE/WM combinations and this script has always been needed. Currently using Niri and Mi Shell and the script works just fine.


Posted

10:06 22-10-2022