Difference between revisions of "Shutdown Pressing Power Button"

From ArchWiki
Jump to: navigation, search
m (Added link to more information about dbus and ksmserver)
(where I found my solution at least)
(45 intermediate revisions by 21 users not shown)
Line 1: Line 1:
[[Category:Power management (English)]]
+
[[Category:Power management]]
[[Category:HOWTOs (English)]]
+
[[es:Shutdown Pressing Power Button]]
 +
[[it:Shutdown Pressing Power Button]]
 +
[[ru:Shutdown Pressing Power Button]]
 +
[[uk:Shutdown Pressing Power Button]]
 +
[[zh-CN:Shutdown Pressing Power Button]]
 +
{{stub|reason=should likely just be a redirect now}}
 +
First of all, make sure that {{ic|button}} [[Kernel modules|module]] is loaded (check the output of {{ic|lsmod}}). If it is not, load it manually and set it to load at boot.
  
{{i18n_links_start}}
+
{{ic|logind}} handles the event from pressing the power key, and the behaviour can be configured in {{ic|/etc/systemd/logind.conf}}. See https://wiki.archlinux.org/index.php/Systemd#ACPI_power_management for more information.
{{i18n_entry|English|Shutting system down by pressing the power button}}
+
{{i18n_entry|Italiano|Arrestare il sistema premendo il pulsante di accensione}}
+
{{i18n_entry|Русский|Выключение компьютера нажатием кнопки Power}}
+
{{i18n_entry|Українська|Вимкнення_системи_кнопкою_Power}}
+
{{i18n_entry|简体中文|使用电源开关关闭系统}}
+
{{i18n_entry|Español|Apagar el sistema pulsando el botón de apagado}}
+
{{i18n_links_end}}
+
 
+
If you want to shutdown your system by simply pressing the power button, do the following:
+
 
+
Install acpid package, if there is no hal in the DAEMONS array in rc.conf add acpid to it and create a file in ''/etc/acpi/events/'' named ''power'' with following content:
+
 
+
<pre>
+
# /etc/acpi/events/power
+
# This is called when the user presses the power button
+
 
+
event=button/power (PWR.||PBTN)
+
action=/sbin/poweroff
+
</pre>
+
 
+
To be able to test it start the acpid daemon:
+
/etc/rc.d/acpid start
+
 
+
From now on pressing the power button (lightly, not for few seconds) should properly shutdown the system.
+
{{i18n_entry|Español|Apagar el sistema pulsando el botón de apagado}}
+
Note that if you have '''hibernate''' configured and working you may want to change the last line with:
+
<pre>
+
action=/usr/sbin/hibernate
+
</pre>
+
 
+
However, if you're using more sophisticated WM, you should use its own shutdown call, so it'd save its session etc.  
+
 
+
To accomplish it in '''KDE 3''', simply change the action to:  
+
''action=/opt/kde/bin/dcop --all-users --all-sessions ksmserver ksmserver logout 0 2 0''
+
 
+
For '''KDE 4''', dcop is being phased out in favour of dbus, so as well as the above you could also use:
+
''action=/usr/bin/qdbus org.kde.ksmserver /KSMServer logout 0 2 0''
+
More information on using dbus is [http://samwiseandthestereotypical.blogspot.com/2008/09/using-dbus-and-ksmserver-to-logout-and.html here]
+
Likewise for '''XFCE4.4''' change the action line to:
+
''action=echo POWEROFF | /usr/lib/xfce4/xfsm-shutdown-helper''
+
 
+
 
+
Note: For a more robust solution [If you are facing frequent WM crashes or working on a sacrificial PC for developing or testing your software...], you should take a look at "/usr/src/linux/Documentation/sysrq.txt", which is a kernel facility for yielding you [the user...] the CPU so that it could be used for any *rescue* work.
+

Revision as of 20:14, 4 November 2012

Tango-document-new.pngThis article is a stub.Tango-document-new.png

Notes: should likely just be a redirect now (Discuss in Talk:Shutdown Pressing Power Button#)

First of all, make sure that button module is loaded (check the output of lsmod). If it is not, load it manually and set it to load at boot.

logind handles the event from pressing the power key, and the behaviour can be configured in /etc/systemd/logind.conf. See https://wiki.archlinux.org/index.php/Systemd#ACPI_power_management for more information.