Difference between revisions of "Shutdown Pressing Power Button"

From ArchWiki
Jump to: navigation, search
m (Added i18n Spanish link)
(Added alternative kde logout method using dbus instead of dcop)
Line 35: Line 35:
 
However, if you're using more sophisticated WM, you should use its own shutdown call, so it'd save its session etc.  
 
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''', simply change the action to:  
+
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''
 
  ''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 org.kde.KSMServerInterface.logout 0 2 0''
  
 
Likewise for '''XFCE4.4''' change the action line to:  
 
Likewise for '''XFCE4.4''' change the action line to:  

Revision as of 10:10, 15 August 2008

Template:I18n links start Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n links end

If you want to shutdown your system by simply pressing the power button, do the following:

Install acpid package, add acpid to the DAEMONS array in rc.conf and create a file in /etc/acpi/events/ named power with following content:

# /etc/acpi/events/power
# This is called when the user presses the power button

event=button/power (PWR.||PBTN)
action=/sbin/poweroff

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. Template:I18n entry Note that if you have hibernate configured and working you may want to change the last line with:

action=/usr/sbin/hibernate

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 org.kde.KSMServerInterface.logout 0 2 0

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.