Hi Folks, Cybermoron posted a thread on creating a nifty shutdown button on the Win 7
desktop to make shutdown\restart easier.
I posted that I use a similar method to shutdown\restart my Ubuntu installs using a simple
He suggested I share that here in the Linux section so here goes.
First I can't take credit for the script it was created by another individual over at the Ubuntu forums.
Below is the script text.
The first thing to do is to right click an empty area of your desktop and choose "create document>empty file".
def restart(self, event):
command = "sudo shutdown -r now"
def shutdown(self, event):
command = "sudo shutdown -h now"
def cancel(self, event):
def delete_event(self, widget, event, data=None):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.box1 = gtk.HBox(False, 0)
self.button1 = gtk.Button("Restart")
self.box1.pack_start(self.button1, True, True, 0)
self.button2 = gtk.Button("Shutdown")
self.box1.pack_start(self.button2, True, True, 0)
self.button3 = gtk.Button("Cancel")
self.box1.pack_start(self.button3, True, True, 0)
pwr = power()
Open the resulting empty file in gedit or another suitable text editor and copy\paste all the text from the script above into the empty document file.
Save and name the file power_options.
Next right click the newly created power_options file and select properties>permissions and make sure that "allow executing file as a program" is selected.
All other permissions should be correct if you created the file on your desktop.
Close the properties dialog box and move the file to your /home/<your user name> folder
where <your user name> is your user name without the <> symbols.
The two commands below should be done in terminal as user.
Do not do as root.
You can do this from the terminal by typing
and clicking enter.
The D in desktop must be uppercase.
again your own user name without the <> symbols and click enter.
cp power_options /home/<your user name>
Alternatively if you have a desktop shortcut to your /home directory just cut and copy the file to it.
Now that the file is in your /home directory we will now make a desktop launcher (shortcut) to it.
Right click a blank area of your desktop and choose "Create Launcher..".
In the resulting dialog box make sure "application" is selected in the type: dropdown menu.
In the name: field name then launcher anything you want, I chose Quit.
In the command: field type python /home/<your user name>/power_options, again using your actual user name without <> where it says <your user name>.
In the upper left corner of the launcher dialog box is a generic icon.
Click this icon to change the icon to a more acceptable one from the list.
If you have an icon of your own then place it in your /home directory and navigate to it using the browse feature.
attached below is the icon I use.
If you want to use this icon just click on the attachment thumbnail and right click the resulting image and choose "save image as..." and save it to your /home folder.
It will be saved as a .png.
Navigate to that icon file as instructed above to use it as your icon.
Click ok when done and you should have a brand new launcher on your desktop with
the icon of your choice.
Right click the new launcher and choose properties>permissions and make sure "allow executing file as a program" is selected, close the properties box and you launcher is ready for use.
When clicked your new shutdown button will open a small dialog box where you can select shutdown, restart or cancel.
I've tested this on all versions of Ubuntu from Dapper Drake (Ubuntu 6.04 LTS) to the latest Lucid Lynx (Ubuntu 10.04 LTS) and the launcher works very well.
I haven't tested it the KDE versions (Kubuntu) but it should work just as well.
It should work on other debian based Linux distros but I haven't tested it.
Have fun with your new Desktop shutdown button.