I have an old laptop and I installed Ubuntu 20.04 LTS Server edition (no GUI, just CLI). It managed via SSH so its display is unnecessary. I would like to turn off the display when I close the lid, and turn on again if I open it.
I've successfully configured acpid to manage the display.
In /etc/acpi/events I created a file:
event=button/lid.*
action=/etc/acpi/lid.sh
The script:
#!/bin/sh
grep -q closed /proc/acpi/button/lid/LID/state
if [ $? = 0 ]
then
# close action
setterm --blank force
else
# open action
setterm --blank poke
fi
If I run this script manually, it works perfectly, however it seems that acpi can't run the script:
$ sudo journalctl -u acpid -f
...
Jul 04 20:03:01 server acpid[1179]: received input layer event "button/lid LID close"
Jul 04 20:03:01 server acpid[1179]: rule from /etc/acpi/events/lid matched
Jul 04 20:03:01 server acpid[1353]: executing action "/etc/acpi/lid.sh"
Jul 04 20:03:01 server acpid[1179]: action exited with status 1
Jul 04 20:03:01 server acpid[1179]: 1 total rule matched
Jul 04 20:03:01 server acpid[1179]: completed input layer event "button/lid LID close"
...
Error: action exited with status 1 (not 0)
If i know right, exit code 1 is a permission issue (operation not permitted). I don't know why is it "not permitted", because I don't need to use sudo
to run this script.