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.
Table of Contents
1 Dialog with pressing power button
When pressing power button, The dialog "Screen Lock, Suspend, Reboot and Shutdown" will be displayed.
This dialog prevents guest machine shutdown and reboot from host machine operation.
In case of libvirt, when running "virsh shutdown / virsh reboot" from host machine, this dialog will be displayed on guest machine. You need to select dialog on guest machine. By the way, running "virsh destroy" provides hardware power off.
2 Append /usr/share/acpi-support/power-funcs
When pressing power button, /etc/acpi/powerbtn.sh will be called. /etc/acpi/powerbtn.sh will call /usr/share/acpi-support/power-funcs if it is exists, and display the disalog.
/usr/share/acpi-support/power-funcs is not exists by default. Append /usr/share/acpi-support/power-funcs for running shutdown.
$ sudo su -c 'cat <<EOF > /usr/share/acpi-support/power-funcs #!/bin/sh test -f /var/lock/acpisleep && exit 0 sudo shutdown -h now EOF ' $ sudo chmod a+x /usr/share/acpi-support/power-funcs
This will help running "virsh reboot / virsh shutdown".