Ubuntu – How to enable the pc power button at the lock screen


I would like my Ubuntu 14.04 to shut down (shutdown -h now) when I press the physical power button on the PC, regardless of whether it is locked or not. Works great on every windows machine, why doesn't this work on Ubuntu?

It has been suggested to "shortcircuit" /etc/acpi/powerbtn.sh by adding the command before if pidof x $PMS > /dev/nullso it always initiates shutdown when pressed but I haven't gotten this working either.

Best Answer

It only works for me if I short circuit the /etc/acpi/powerbtn.sh completely by inserting

shutdown -h now

at the very beginning. It's still a hack but now it works every time.