4

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 Confirmation dialog on physical hardware

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 :

gnome-control-center power on physical hardware

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:

Ubuntu 16.04 LTS asks for action after pressing power button

or as Ubuntu MATE 18.04 LTS do:

Ubuntu MATE 18.04 LTS asks for action after pressing power button

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):

gnome-control-center power in VM

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?

2
  • 1
    Just tested on May 6 2018 18.04 upgrade and the power off menu appears for about 1 second before shutting down Unity. Will grep 18.04 gsetring differences to 16.04 when I get home later. May 6, 2018 at 19:51
  • As independent test I tried ArchLinux with latest GNOME and MATE on VirtualBox: after <RightCtrl+H> MATE asks, GNOME shutdowns quietly.
    – N0rbert
    May 6, 2018 at 20:44

1 Answer 1

1

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:

gsettings list-recursively | sed 's/  */\n/;s/  */\n/;s/\&/\&amp;/g' | yad --list --title "gsettings" --item-seperator='\n' --width=1800 --height=800 --wrap-width=600 --column=Group --column=Key --column=Setting --no-markup

sorted by "key" and scrolled down to "power". You can confirm your settings with:

$ gsettings get org.gnome.settings-daemon.plugins.power power-button-action
'interactive'

Checking with Ubuntu 16.04 set it the same using:

$ gsettings set org.gnome.settings-daemon.plugins.power power-button-action suspend

Double check the settings:

$ gsettings get org.gnome.settings-daemon.plugins.power power-button-action
'suspend'

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:

Ubuntu Power Button.gif

I borrowed this .gif from another answer I wrote. It shows how the lock screen option was missing and how to bring it back.

1
  • It is OK on physical hardware, but does not work on VirtualBox (5.1 in my case).
    – N0rbert
    May 7, 2018 at 9:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .