Thursday, April 28, 2011

Shutdown and reboot buttons on your Ubuntu desktop


Some time ago I wanted to place a button on the desktop to allow me to turn off the computer. More than anything pigeon, for that of not having to go to the menu to turn off the computer. You see nothing special. Time whim.

Not that he has devoted much time to this, but of course when I saw the other day, it made me laugh, and then today's article.

The sense of the matter is that we edit the sudoers file to allow the use of shutdown or reboot, but we do it through D-Bus. This allows us to put a couple of buttons to shutdown or reboot (or more) on the desktop, which was what I wanted, leaving the thing as this:


Code Shutdown, Reboot, suspend and hibernate
Shutdown


The file you have to give execute permission. For example if we call it "Shutdown":

chmod +x Shutdown
The same will be done to the other commands:
dbus-send –system –print-reply –dest=org.freedesktop.Hal \
/org/freedesktop/Hal/devices/computer \
org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown
Reboot
dbus-send –system –print-reply –dest=org.freedesktop.Hal \
/org/freedesktop/Hal/devices/computer \
org.freedesktop.Hal.Device.SystemPowerManagement.Reboot
Suspend
dbus-send –system –print-reply –dest=org.freedesktop.Hal \
/org/freedesktop/Hal/devices/computer \
org.freedesktop.Hal.Device.SystemPowerManagement.Suspend int32:1
Hibernate
dbus-send –system –print-reply –dest=org.freedesktop.Hal \
/org/freedesktop/Hal/devices/computer \
org.freedesktop.Hal.Device.SystemPowerManagement.Hibernate
Button code
Shutdown


The file you'll have to save as Shutdown.desktop, with the following contents:
#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=/home/atareao/Desktop/reboot.sh
Name=Reboot
Icon=/usr/share/icons/Faenza/actions/scalable/media-playlist-repeat.svg
Exec have to change to the address where you have located the file to execute.
If this article was useful and you want to help us to grow Subscribing to our feed or Click "Like" in our Facebook page ,or follow us via Twitter or subscribing to our feed.

People who read this post also read :



0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More