You are not logged in.
i'm using fluxbox and i got a little tired of alt-tabbing to the terminal every time and invoking the "shutdown" command (even though i have a neat alias for it).
(i suck at programming (in fact, i never made a single GUI program, i'm just a PHP coder mostly) so i can't make one myself)
any suggestions? thanks in advance!
Last edited by kiruch (2009-07-05 14:37:19)
Offline
I made a small one in python+gtk.
It have keyboard shortcuts (the shortcurt is the first letter of option) if you need to change the commands the source code is simple. If you need help post it. You need to change it for fluxbox I dont know how to exit from fluxbox, sorry.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pygtk
pygtk.require('2.0')
import gtk
import os
class DoTheLogOut:
# Cancel/exit
def delete_event(self, widget, event, data=None):
gtk.main_quit()
return False
# Logout
def logout(self, widget):
os.system("openbox --exit")
# Reboot
def reboot(self, widget):
os.system("sudo shutdown -r now && openbox --exit")
# Shutdown
def shutdown(self, widget):
os.system("sudo shutdown -h now && openbox --exit")
# Hibernate
def hibernate(self, widget):
os.system("sudo hibernate")
def __init__(self):
# Create a new window
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_title("Exit? Choose an option:")
self.window.set_resizable(False)
self.window.set_position(1)
self.window.connect("delete_event", self.delete_event)
self.window.set_border_width(20)
# Create an accelgroup and add it to the window
accel_group = gtk.AccelGroup()
self.window.add_accel_group(accel_group)
# Create a box to pack widgets into
self.box1 = gtk.HBox(False, 0)
self.window.add(self.box1)
# Create cancel button
self.button1 = gtk.Button("Cancel")
self.button1.set_border_width(10)
self.button1.connect("clicked", self.delete_event, "closed")
self.box1.pack_start(self.button1, True, True, 0)
self.button1.add_accelerator("clicked", accel_group,
gtk.gdk.keyval_from_name('Escape'), 0, 0)
self.button1.add_accelerator("clicked", accel_group,
gtk.gdk.keyval_from_name('c'), 0, 0)
self.button1.show()
# Create logout button
self.button2 = gtk.Button("Logout")
self.button2.set_border_width(10)
self.button2.connect("clicked", self.logout)
self.box1.pack_start(self.button2, True, True, 0)
self.button2.add_accelerator("clicked", accel_group,
gtk.gdk.keyval_from_name('l'), 0, 0)
self.button2.show()
# Create reboot button
self.button3 = gtk.Button("Reboot")
self.button3.set_border_width(10)
self.button3.connect("clicked", self.reboot)
self.box1.pack_start(self.button3, True, True, 0)
self.button3.add_accelerator("clicked", accel_group,
gtk.gdk.keyval_from_name('r'), 0, 0)
self.button3.show()
# Create shutdown button
self.button4 = gtk.Button("Shutdown")
self.button4.set_border_width(10)
self.button4.connect("clicked", self.shutdown)
self.box1.pack_start(self.button4, True, True, 0)
self.button4.add_accelerator("clicked", accel_group,
gtk.gdk.keyval_from_name('s'), 0, 0)
self.button4.show()
# Create hibernate button
self.button5 = gtk.Button("Hibernate")
self.button5.set_border_width(10)
self.button5.connect("clicked", self.hibernate)
self.box1.pack_start(self.button5, True, True, 0)
self.button5.add_accelerator("clicked", accel_group,
gtk.gdk.keyval_from_name('h'), 0, 0)
self.button5.show()
self.box1.show()
self.window.show()
def main():
gtk.main()
if __name__ == "__main__":
run_it = DoTheLogOut()
main()
Offline
There's shutdown-dialog in AUR.
Offline
You can keep it real simple by just adding a shutdown and reboot option to your menu if that suits your purpose. Using sudo, add a line or two to /etc/sudoers file.
username ALL=(ALL) NOPASSWD: /sbin/halt, /sbin/reboot
Then just add to your .fluxbox/menu
[exit] (Exit)
[exec] (Reboot) {sudo reboot}
[exec] (Shutdown) {sudo halt}
It's an option!
Time is a great teacher, but unfortunately it kills all its pupils ... - Louis Hector Berlioz
Offline
You can also use this little script (Xdialog is needed)
#!/bin/sh
DIALOG=Xdialog
$DIALOG --allow-close\
--stdout\
--title 'Exit'\
--menu 'Choose action..'\
15 50 10 \
'Shutdown' "" \
'Reboot' "" \
'Suspend to RAM' "" \
'Suspend to Disk' "" \
1> /tmp/exitval.$$ 2> /dev/null
ACTION=`cat /tmp/exitval.$$`
rm -f /tmp/exitval.$$
case $ACTION in
'Shutdown') sudo halt ;;
'Reboot') sudo reboot ;;
'Suspend to RAM') sudo s2ram ;;
'Suspend to Disk') sudo s2disk ;;
*) exit ;;
esac
Last edited by mzapotoczny (2009-07-05 18:57:27)
Offline
thank you, guys. all of you!!
Offline