Created
August 16, 2009 19:39
-
-
Save dennyhalim/168733 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# | |
# Multi-call script providing GTK boxes to manage a desktop following | |
# Freedesktop standards. | |
# | |
# (C) GNU gpl v3 - SliTaz GNU/Linux 2008. | |
# | |
VERSION=20080719 | |
# Glade XML file path. | |
GLADE_XML=/usr/share/slitaz-tools/glade | |
# Export script path and other if needed so we can use them in 'quote'. | |
export BIN=$0 | |
export AUTOSTART_SCRIPT=$HOME/.config/openbox/autostart.sh | |
# Standard directories. | |
mkdir -p $HOME/Desktop $HOME/.local/share/applications | |
# Get the active locale (default to English). | |
case $LANG in | |
es*) | |
lang="es" | |
NEW_FOLDER_LABEL="Create a new folder on the desktop:" | |
FOLDER_ENTRY_MSG="dirname" | |
NEW_FILE_LABEL="Create a new file on the desktop:" | |
FILE_ENTRY_MSG="filename" | |
ADD_ICON_LABEL="Add some desktop icons" | |
CHARS_SIZE="64" | |
DESKTOP_DIALOG_TAZUSB="Save filesystem using compression" | |
DESKTOP_DIALOG_LABEL="Session logout, system shutdown or reboot" | |
DESKTOP_LOGOUT_BUTTON="Logout X session" | |
DESKTOP_SHUTDOWN_BUTTON="Shutdown computer" | |
DESKTOP_REBOOT_BUTTON="Reboot system" ;; | |
fr*) | |
lang="fr" | |
NEW_FOLDER_LABEL="Créer un nouveau dossier sur le bureau:" | |
FOLDER_ENTRY_MSG="dossier" | |
NEW_FILE_LABEL="Créer un nouveau fichier sur le bureau:" | |
FILE_ENTRY_MSG="fichier" | |
ADD_ICON_LABEL="Ajouter des icônes de bureau" | |
CHARS_SIZE="72" | |
DESKTOP_DIALOG_TAZUSB="Enregistrer le système avec la compression" | |
DESKTOP_DIALOG_LABEL="Déconnexion, arrêt ou redémarrage du système" | |
DESKTOP_LOGOUT_BUTTON="Fermer la session X" | |
DESKTOP_SHUTDOWN_BUTTON="Eteindre le système" | |
DESKTOP_REBOOT_BUTTON="Redémarrer le système" ;; | |
*) | |
lang="" | |
NEW_FOLDER_LABEL="Create a new folder on the desktop:" | |
FOLDER_ENTRY_MSG="dirname" | |
NEW_FILE_LABEL="Create a new file on the desktop:" | |
FILE_ENTRY_MSG="filename" | |
ADD_ICON_LABEL="Add some desktop icons" | |
CHARS_SIZE="64" | |
DESKTOP_DIALOG_TAZUSB="Save filesystem using compression" | |
DESKTOP_DIALOG_LABEL="Session logout, system shutdown or reboot" | |
DESKTOP_LOGOUT_BUTTON="Logout X session" | |
DESKTOP_SHUTDOWN_BUTTON="Shutdown computer" | |
DESKTOP_REBOOT_BUTTON="Reboot system" ;; | |
esac | |
# X session/system logout. | |
# | |
DESKTOP_DIALOG=" | |
<window title=\"Exit Menu\" icon-name=\"user-desktop\" skip_taskbar_hint=\"true\"> | |
<vbox> | |
<pixmap> | |
<input file>/usr/share/icons/Tango/32x32/places/user-desktop.png</input> | |
</pixmap> | |
<hbox> | |
<text use-markup=\"true\" width-chars=\"$CHARS_SIZE\"> | |
<label> | |
\"<b>$DESKTOP_DIALOG_LABEL</b> | |
\" | |
</label> | |
</text> | |
</hbox>" | |
# | |
# EXTRA="COMP=none; [ \$LZMA = true ] && COMP=lzma; [ \$GZIP = true ] && COMP=gzip; [ \$TAZUSB_WRITE = true ] && { subox \"xterm -e '/usr/bin/tazusb writefs \$COMP'\"; sleep 1; while ps x | grep -v grep | grep -q tazusb; do sleep 1; done; };" | |
# [ -f /home/boot/rootfs.gz ] || { TAZUSB_DIALOG=""; EXTRA=""; } | |
# Logout for Openbox or JWM and system shutdown or reboot. | |
ACTIONS=" | |
<hbox> | |
<button> | |
<label>$DESKTOP_LOGOUT_BUTTON</label> | |
<input file icon=\"video-display\"></input> | |
<action>$EXTRA openbox --exit || jwm -exit</action> | |
<action type=\"exit\">Exit</action> | |
</button> | |
<button> | |
<label>$DESKTOP_SHUTDOWN_BUTTON</label> | |
<input file icon=\"system-shutdown\"></input> | |
<action>$EXTRA poweroff</action> | |
<action type=\"exit\">Exit</action> | |
</button> | |
<button> | |
<label>$DESKTOP_REBOOT_BUTTON</label> | |
<input file icon=\"reload\"></input> | |
<action>$EXTRA reboot</action> | |
<action type=\"exit\">Exit</action> | |
</button> | |
<button cancel> | |
<action type=\"exit\">Exit</action> | |
</button> | |
</hbox> | |
</vbox> | |
</window>" | |
export DESKTOP_DIALOG=${DESKTOP_DIALOG}${ACTIONS} | |
gtkdialog --center --program=DESKTOP_DIALOG >/dev/null | |
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# A littel shutdown menu for openbox | |
# http://bbs.archlinux.org/viewtopic.php?id=44150 | |
# Contact: | |
# Name : Markus Verweyen | |
# Email: [email protected] | |
# | |
# Requierments: | |
# pygtk | |
# sudo | |
# python | |
# gtk | |
# | |
# Scheduling: | |
# You need the following entry in the /etc/sudoers file. | |
# yourUserName ALL=(ALL) NOPASSWD:/sbin/shutdown | |
import os | |
import gtk | |
import gtk.glade | |
import pygtk | |
import sys | |
# Class Commands | |
class Commands: | |
def logout(self): | |
os.system("/usr/bin/killall openbox") | |
def reboot(self): | |
os.system("/usr/bin/sudo shutdown -r now") | |
def shutdown(self): | |
os.system("/usr/bin/sudo shutdown -h now") | |
# Class Shutdown gui | |
class ShutdownGui(Commands): | |
def __init__(self): | |
self.gladefile = sys.path[0] + "/shutdown_gui.glade" | |
self.wTree = gtk.glade.XML(self.gladefile) | |
self.ShutdownBox = self.wTree.get_widget("ShutdownBox") | |
self.ShutdownBox.connect('delete-event', gtk.main_quit) | |
self.ShutdownBox.set_keep_above(True) | |
self.set_button_signals() | |
def show(self): | |
self.ShutdownBox.show_all() | |
def set_button_signals(self): | |
button_dictonary = {"on_LogoutButton_clicked" : self.on_logout, | |
"on_RebootButton_clicked" : self.on_reboot, | |
"on_ShutdownButton_clicked" : self.on_shutdown, | |
"on_CancelButton_clicked" : self.on_cancel} | |
self.wTree.signal_autoconnect(button_dictonary) | |
def on_logout(self, data): | |
self.logout() | |
def on_reboot(self, data): | |
self.reboot() | |
def on_shutdown(self, data): | |
self.shutdown() | |
def on_cancel(self, data): | |
gtk.main_quit() | |
# Main Program | |
def main(): | |
shutbox = ShutdownGui() | |
shutbox.show() | |
gtk.main() | |
# Script Trick | |
if __name__ == "__main__": | |
main() | |
sys.exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd"> | |
<!--Generated with glade3 3.4.1 on Sat Feb 16 01:52:03 2008 --> | |
<glade-interface> | |
<widget class="GtkWindow" id="ShutdownBox"> | |
<property name="width_request">330</property> | |
<property name="height_request">94</property> | |
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> | |
<property name="title" translatable="yes">Openbox Shutdown Menu</property> | |
<property name="resizable">False</property> | |
<property name="modal">True</property> | |
<property name="window_position">GTK_WIN_POS_CENTER</property> | |
<property name="icon">help-browser.png</property> | |
<property name="skip_taskbar_hint">True</property> | |
<property name="skip_pager_hint">True</property> | |
<property name="urgency_hint">True</property> | |
<property name="deletable">False</property> | |
<property name="opacity">0</property> | |
<child> | |
<widget class="GtkLayout" id="layout1"> | |
<property name="visible">True</property> | |
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> | |
<child> | |
<widget class="GtkButton" id="ShutdownButton"> | |
<property name="width_request">150</property> | |
<property name="height_request">32</property> | |
<property name="visible">True</property> | |
<property name="can_focus">True</property> | |
<property name="receives_default">True</property> | |
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> | |
<property name="label" translatable="yes">_Shutdown</property> | |
<property name="use_underline">True</property> | |
<property name="response_id">0</property> | |
<signal name="clicked" handler="on_ShutdownButton_clicked"/> | |
</widget> | |
<packing> | |
<property name="x">10</property> | |
<property name="y">10</property> | |
</packing> | |
</child> | |
<child> | |
<widget class="GtkImage" id="image3"> | |
<property name="width_request">24</property> | |
<property name="height_request">24</property> | |
<property name="visible">True</property> | |
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> | |
<property name="stock">gtk-stop</property> | |
</widget> | |
<packing> | |
<property name="x">14</property> | |
<property name="y">14</property> | |
</packing> | |
</child> | |
<child> | |
<widget class="GtkButton" id="RebootButton"> | |
<property name="width_request">150</property> | |
<property name="height_request">32</property> | |
<property name="visible">True</property> | |
<property name="can_focus">True</property> | |
<property name="receives_default">True</property> | |
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> | |
<property name="label" translatable="yes">_Reboot</property> | |
<property name="use_underline">True</property> | |
<property name="response_id">0</property> | |
<signal name="clicked" handler="on_RebootButton_clicked"/> | |
</widget> | |
<packing> | |
<property name="x">170</property> | |
<property name="y">10</property> | |
</packing> | |
</child> | |
<child> | |
<widget class="GtkImage" id="image2"> | |
<property name="width_request">24</property> | |
<property name="height_request">24</property> | |
<property name="visible">True</property> | |
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> | |
<property name="stock">gtk-refresh</property> | |
</widget> | |
<packing> | |
<property name="x">174</property> | |
<property name="y">14</property> | |
</packing> | |
</child> | |
<child> | |
<widget class="GtkButton" id="LogoutButton"> | |
<property name="width_request">150</property> | |
<property name="height_request">32</property> | |
<property name="visible">True</property> | |
<property name="can_focus">True</property> | |
<property name="receives_default">True</property> | |
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> | |
<property name="label" translatable="yes">_Logout</property> | |
<property name="use_underline">True</property> | |
<property name="response_id">0</property> | |
<signal name="clicked" handler="on_LogoutButton_clicked"/> | |
</widget> | |
<packing> | |
<property name="x">10</property> | |
<property name="y">52</property> | |
</packing> | |
</child> | |
<child> | |
<widget class="GtkImage" id="image3"> | |
<property name="width_request">24</property> | |
<property name="height_request">24</property> | |
<property name="visible">True</property> | |
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> | |
<property name="stock">gtk-quit</property> | |
</widget> | |
<packing> | |
<property name="x">14</property> | |
<property name="y">56</property> | |
</packing> | |
</child> | |
<child> | |
<widget class="GtkButton" id="CancelButton"> | |
<property name="width_request">150</property> | |
<property name="height_request">32</property> | |
<property name="visible">True</property> | |
<property name="can_focus">True</property> | |
<property name="receives_default">True</property> | |
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> | |
<property name="label" translatable="yes">_Cancel</property> | |
<property name="use_underline">True</property> | |
<property name="response_id">0</property> | |
<signal name="clicked" handler="on_CancelButton_clicked"/> | |
</widget> | |
<packing> | |
<property name="x">170</property> | |
<property name="y">52</property> | |
</packing> | |
</child> | |
<child> | |
<widget class="GtkImage" id="image4"> | |
<property name="width_request">24</property> | |
<property name="height_request">24</property> | |
<property name="visible">True</property> | |
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> | |
<property name="stock">gtk-undo</property> | |
</widget> | |
<packing> | |
<property name="x">174</property> | |
<property name="y">56</property> | |
</packing> | |
</child> | |
</widget> | |
</child> | |
</widget> | |
</glade-interface> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment