I rewrite this question to be clear. I have problems only on VirtualBox.
1. Physical hardware
If press Power Button on physical hardware:
- on console ttys system shutdowns
- on the GDM system goes to sleep (suspends)
- in GNOME session it goes to suspend
If I manually run gsettings set org.gnome.settings-daemon.plugins.power power-button-action interactive
GNOME asks me what to do.
Power Off
The system will power off automatically in 60 seconds
Cancel | Restart | Power Off
It is expected behavior.
But currently there is no such option in GUI (gnome-control-center power
), request for enhancement was filed as bug 1769614 :
2. VirtualBox guest
2.1. Problem
I have ordinary Ubuntu 18.04 LTS installed as VirtualBox guest ( ! ! ! ).
When I press RightCtrl+H (or Machine->ACPI Shutdown) to initiate reaction on ACPI Power Button press it shutdowns immediately.
I expect that Ubuntu 18.04 LTS with default desktop would ask me about action on pressing power button as Ubuntu 16.04 LTS do:
or as Ubuntu MATE 18.04 LTS do:
2.2. Analysis
I did some investigations with no positive results.
System journal reports that systemd-logind
may handle ACPI Power key.
Its settings are default:
$ cat /etc/systemd/logind.conf | grep -i power
#HandlePowerKey=poweroff
#PowerKeyIgnoreInhibited=no
I have set GNOME to use interactive reaction on Power button:
$ gsettings list-recursively | grep -i power | grep -i button
org.gnome.settings-daemon.plugins.power button-power 'interactive'
org.gnome.settings-daemon.plugins.power power-button-action 'interactive'
Once more interesting thing that I do not have When the Power Button is pressed in VM (it is bug 1769623):
Setting HandlePowerKey=ignore
in /etc/systemd/logind.conf does not help:
sudo sed -i "s/#HandlePowerKey=poweroff/HandlePowerKey=ignore/" /etc/systemd/logind.conf
so I set it back
sudo sed -i "s/HandlePowerKey=ignore/#HandlePowerKey=poweroff/" /etc/systemd/logind.conf
So I reported bug 1769372 to LaunchPad.
Note: in terminal session aka multi-user.target
(systemctl isolate multi-user.target
) all variables from /etc/systemd/logind.conf are sourced normally. So the problem is with GNOME session (systemctl isolate graphical.target
) in gnome-settings-daemon
or something other.
Question
How to stop such behavior in VM?
Does anyone have the same problem in VM or real hardware?
Best Answer
I ran a fresh upgrade on May 6, 2018 on Ubuntu 16.04 clone to 18.04 and confirmed when pressing the power button the "old" menu appears for a split second and then the machine suspends.
I checked
gsettings
using:sorted by "key" and scrolled down to "power". You can confirm your settings with:
Checking with Ubuntu 16.04 set it the same using:
Double check the settings:
You don't need to reboot. Simply press the power button and now the menu will come up and stay where you can select from:
I borrowed this
.gif
from another answer I wrote. It shows how the lock screen option was missing and how to bring it back.