I'm trying to run a script once I push the power button instead of having my machine turn off. I'm running Ubuntu Server 13.04, but any answers also need to work on Server 14.04.
I've looked at ACPI events and such, tried editing the
/etc/acpi/events/powerbtn files but no luck anywhere.
So then I after reading this page https://wiki.archlinux.org/index.php/acpid, I ran
sudo journalctl -f as instructed, but that didn't work. So I tried
sudo acpi_listen and I got into the ACPI event listener. However, even from in there, pushing the power button gave me no output at all.
Is there another service in place which catches the power button events before ACPI? What files would I then need to edit to execute my script when the power button is pushed?
I've also tried
sudo xev and that gave me no output on the power button either.
EDIT: I also have a Ubuntu Desktop system and on that system I can get output from ACPI and I can edit the
/etc/acpi scripts. Is there something installed with Unity that miraculously enables ACPI?
EDIT AGAIN: Ended up doing a fresh install...ACPI worked. I guess I messed something up when I was experimenting and first tried to find a solution to this problem. What I did was place my python script in
/etc/acpi/ and then added the following two lines to the top of
sudo python my_python_script.py exit 0
And it worked. Thanks guys.