sudo apt-get install acpid
pico /etc/acpi/events/power
File contents:
event=button/power
action=/etc/acpi/powerbtn.sh %e
pico /etc/acpi/powerbtn.sh
File contents:
exec poweroff
chmod +x /etc/acpi/powerbtn.sh
pico /etc/init/acpid.conf
File contents:
exec acpid -c /etc/acpi/events -s /var/run/acpid.socket