Debian 8: Shutdown with pressing power button

This article will describe shutdown with pressing power button. This is not long press power button which will cause hardware power off. This will cause interrupt to software.

1 Power button action is suspend

Debian 8's power button action is suspend by default via /etc/acpi/events/powerbtn-acpi-support. This is for laptop setting which can be suspend when closing laptop.

2 Append /etc/acpi/events/powerbtn

If /etc/acpi/events/powerbtn is exists, /etc/acpi/events/powerbtn will be executed instead of /etc/acpi/events/powerbtn-acpi-support.

Append /etc/acpi/events/powerbtn which runs poweroff command. Reboot Debian 8 after appending.

$ sudo su -c 'cat <<EOF > /etc/acpi/events/powerbtn
event=button[ /]power
action=/sbin/poweroff
EOF
'
$ sudo reboot

If you want to keep running laptop when closing laptop, like connecting via SSH, change poweroff command to true command in /etc/acpi/events/powerbtn.