On Fedora 23 I wanted to add custom action when laptop lid is opened. I have installed acpid and created three files:
/etc/acpi/events/lidconf
event=button/lid
action=/etc/acpi/actions/lid.sh "%e"
/etc/acpi/actions/lid.sh
#!/bin/bash
/home/user/Utility/lid.sh "$1"
/home/user/Utility/lid.sh
#!/bin/bash
DISPLAY=:0.0 su user -c "echo $1 >> /home/user/lid.txt"
It works perfectly when I run # /usr/sbin/acpid -f, but not at all when I do # systemctl start acpid.
I have noticed that result of ps command is a bit different.
As root:
root 3796 0.0 0.0 4344 1704 ? Ss 22:24 0:00 /usr/sbin/acpid -f
Using systemd:
root 3918 0.0 0.0 4344 1780 pts/0 S+ 22:25 0:00 /usr/sbin/acpid -f
Why it does not work when started by systemd?
Edit:
I have enabled log for acpid and this is what I get:
received input layer event "button/lid LID open"
rule from /etc/acpi/events/lidconf matched
executing action "/etc/acpi/actions/lid.sh "button/lid LID open""
action exited with status 126
1 total rule matched
completed input layer event "button/lid LID open"
Edit2: ps aux -Z
Systemd:
system_u:system_r:apmd_t:s0 root 5177 0.1 0.0 4348 1756 ? Ss 22:52 0:00 /usr/sbin/acpid -f -l -d
Ran as root:
unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 root 5341 0.0 0.0 4344 1808 pts/0 S+ 22:56 0:00 /usr/sbin/acpid -f -l -d