CentOS 7: Shutdown with pressing power button


Table of Contents

1 Power button action is suspend

CentOS 6’s power button action is shutdown, but CentOS 7’s power button action is suspend as below.

[ 85.247233] Freezing user space processes … (elapsed 0.001seconds) done.[ 85.249541] Freezing remaining freezable tasks … (elapsed 0.001seconds) done.[ 85.251926] Suspending console(s) (use no_console_suspend to debug)

Fedora 22’s power button action is suspend too. But Fedora 23’s power button action is shutdown again. This might be a different way with a way of using default value.

You can change power button action for each user with gsetting and gconf-editor. But you cannot change power button action before login.

In case of virtual machine, you must login to guest machine CentOS 7 for shutdown CentOS 7.

There are some discussion about this power button action like tablet and customizing default value. I think that this action should be shutdown for PC like Fedora 23.

2 Rebuild gnome-settings-daemon

The following script will install gnome-settings-daemon which has shutdown as power button action. After reboot, CentOS 7 can be shutdown with power button.

#!/bin/shsudo yum install -y rpmdevtoolssudo yum-builddep -y gnome-settings-daemonsudo yumdownloader –source gnome-settings-daemonrpm -i gnome-settings-daemon*.src.rpmrm -f gnome-settings-daemon*.src.rpmcd ~/rpmbuildcat <<EOF > SOURCES/button-power-suspend-to-shutdown.patch— gnome-settings-daemon-3.14.4.org/data/org.gnome.settings-daemon.plugins.power.gschema.xml.in.in 2015-04-01 04:47:29.000000000 -0400+++ gnome-settings-daemon-3.14.4/data/org.gnome.settings-daemon.plugins.power.gschema.xml.in.in 2016-10-18 22:16:01.627664826 -0400@@ -57,7 +57,7 @@ </key> <!– See https://bugzilla.gnome.org/show_bug.cgi?id=652183 for rationale –> <key name=”button-power” enum=”org.gnome.settings-daemon.GsdPowerActionType”>- <default>’suspend'</default>+ <default>’shutdown'</default> <summary>Power button action</summary> <description>The action to take when the system power button is pressed.</description> </key>EOFcat <<EOF | patch -p1— a/SPECS/gnome-settings-daemon.spec 2016-10-18 22:44:16.963433081 -0400+++ b/SPECS/gnome-settings-daemon.spec 2016-10-18 22:44:50.565951707 -0400@@ -30,6 +30,8 @@ Patch4: 0001-mouse-Do-not-disable-touchp # https://bugzilla.redhat.com/show_bug.cgi?id=1260081 Patch5: 0001-smartcard-use-NSS_InitContext-instead-of-NSS_Initial.patch+Patch6: button-power-suspend-to-shutdown.patch+ Requires: control-center-filesystem Requires: colord@@ -110,6 +112,7 @@ developing applications that use %{name} %patch3 -p1 -b .power-actions-when-locked %patch4 -p1 -b .touchpad-buttons %patch5 -p1 -b .smartcard-fix+%patch6 -p1 -b .button-power autoreconf -i -fEOFrpmbuild -ba SPECS/gnome-settings-daemon.specsudo yum localinstall -y RPMS/x86_64/gnome-settings-daemon*.rpmsudo reboot

Android | Linux | SDL - Narrow Escape