systemd: Don't act on lid events
After the latest Arch systemd upgrade, I found that my computer attempted to suspend whenever I shut the lid. Of course, suspend doesn’t currently work properly, so it just ended up crashing. This was a result of the changing default behaviour of the several relevant options in logind.conf. From the man page:
HandlePowerKey=, HandleSuspendKey=, HandleHibernateKey=, HandleLidSwitch=
Controls whether logind shall handle the system power and sleep keys and
the lid switch to trigger actions such as system power-off or suspend.
Can be one of ignore, poweroff, reboot, halt, kexec and hibernate. If
ignore logind will never handle these keys. Otherwise the specified
action will be taken in the respective event. Only input devices with
the power-switch udev tag will be watched for key/lid switch events.
HandlePowerKey= defaults to poweroff. HandleSuspendKey= and
HandleLidSwitch= default to suspend. HandleHibernateKey= defaults to
hibernate.
This, to ignore the event triggered by the lid switch, add
HandleLidSwitch=ignore
to your /etc/systemd/logind.conf.
Incidentally, acpid provides more flexible control over actions taken on various power events, like turning on and off the monitor. My /etc/acpid/actions/lm_lid.sh reads in part:
case $(cat /proc/acpi/button/lid/LID0/state | awk '{print $2}') in
closed) XAUTHORITY=$(ps -C xinit -f --no-header | \
sed -n 's/.*-auth //; s/ -[^ ].*//; p') xset -display :0 dpms force off ;;
open) XAUTHORITY=$(ps -C xinit -f --no-header | \
sed -n 's/.*-auth //; s/ -[^ ].*//; p') xset -display :0 dpms force on ;;
esac