Ubuntu 16.04: Shutdown with pressing power button

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/shtest -f /var/lock/acpisleep && exit 0sudo shutdown -h nowEOF’$ sudo chmod a+x /usr/share/acpi-support/power-funcs

This will help running “virsh reboot / virsh shutdown”.

Android | Linux | SDL - Narrow Escape