We have Ubuntu 18.04 desktop machines used in a remote lab setting that may or may not have keyboards and monitors attached to them at any point in time. It is necessary to be able to shutdown and restart the machine with only the power button.
This means Ubuntu must shutdown via the power button consistently whether the user is logged in or the machine just sitting at the login screen.
So far I have set:
Code:
gsettings set org.gnome.settings-daemon.plugins.power button-power shutdown
gsettings set org.gnome.settings-daemon.plugins.power button-hibernate shutdown
gsettings set org.gnome.settings-daemon.plugins.power button-suspend shutdown
gsettings set org.gnome.settings-daemon.plugins.power button-sleep shutdown
and created /etc/acpi/events/power
Code:
event=button/power
action=/etc/acpi/power.sh "%e"
and create /etc/acpi/power.sh
Code:
#!/bin/sh
/sbin/shutdown -h now "Power button pressed"
All of the above allows Ubuntu to shutdown gracefully when a user is logged in and the power button is pressed.
However if the machine is setting at the login screen and the power button is pressed, the machine STILL goes into some type of hibernate mode. If I then press the power button a second time, it comes out of hibernation and the power.sh runs and then it shuts down.
I have tried changing settings in /etc/systemd/logind.conf:
Code:
HandlePowerKey=poweroff
HandleSuspendKey=poweroff
HandleHibernateKey=poweroff
But that doesn't work.