From 9e43bfa22a40bd70b764c66f453465a708d3b7ef Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Tue, 20 Jan 2009 11:39:15 +0100 Subject: update --- #upload-image.sh | 18 ++++----- python/1.py | 2 +- python/shutdown.py | 106 +++++++++++++++++++++++++++++++++++++++++++++++++ python/shutdown.py.old | 88 ++++++++++++++++++++++++++++++++++++++++ screen-locker.sh | 13 +++++- set-background.sh | 16 ++++---- 6 files changed, 223 insertions(+), 20 deletions(-) create mode 100755 python/shutdown.py create mode 100644 python/shutdown.py.old diff --git a/#upload-image.sh b/#upload-image.sh index 31447d5..4fbb0f8 100755 --- a/#upload-image.sh +++ b/#upload-image.sh @@ -1,11 +1,11 @@ -#/bin/dash -#----------------------------------------------------# -# File: upload-image.sh # -# Version: 0.1.0 # -# Date: 2008-10-6 # -# Author: Florian "Bluewind" Pritz # -# Upload image to imagebanana and output url # -#----------------------------------------------------# +#/bin/bash +#---------------------------------------------------- +# File: upload-image.sh +# Version: 0.1.1 +# Date: 2009-01-20 +# Author: Florian "Bluewind" Pritz +# Upload image to imagebanana and output url +#---------------------------------------------------- # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or @@ -20,4 +20,4 @@ # along with this program. If not, see . -curl -F img="@$1" -F "send=Hochladen" -F 'resize=320x240' -H "Expect: " www.imagebanana.com -L | ack -o '(http.*?\/view\/.*?\..{3})' | tail -n 1 +curl -F img="@$1" -F "send=Hochladen" -F 'resize=320x240' -H "Expect: " www.imagebanana.com -L | ack -o -n '(http.*?\/view\/.*?\..{3})' | tail -n 1 diff --git a/python/1.py b/python/1.py index 968fc70..4c35ed0 100644 --- a/python/1.py +++ b/python/1.py @@ -3,5 +3,5 @@ import sys action = sys.stdin.read() -action = action "blub" +action = action + "blub" + "foo" print action diff --git a/python/shutdown.py b/python/shutdown.py new file mode 100755 index 0000000..5f350bb --- /dev/null +++ b/python/shutdown.py @@ -0,0 +1,106 @@ +#!/usr/bin/env python +#----------------------------------------------------# +# File: shutdown.py +# Version: 0.1 +# Date: 2009-01-17 +# Author: Florian "Bluewind" Pritz +# Display a small shutdown Dialog +# Please change the image paths +#----------------------------------------------------# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import gtk +import os + +def create_bbox(title=None, spacing=0, layout=gtk.BUTTONBOX_SPREAD): + bbox = gtk.VButtonBox() + + bbox.set_spacing(spacing) + + buttons = (('Cancel', 'gtk-cancel'), + ('Suspend', 'gnome-session-suspend'), + ('Reboot', 'gnome-session-reboot'), + ('Halt', 'gnome-session-halt') + ) + for text, stock_id in buttons: + image = gtk.Image() + image.set_from_stock(stock_id, gtk.ICON_SIZE_LARGE_TOOLBAR) + b = gtk.Button(text) + b.set_image(image) + b.set_data("user_data", text) + b.connect("clicked", click, b) + b.set_size_request(100, -1) + b.set_alignment(0,1) + bbox.add(b) + + return bbox + +def click(self, button): + ret = button.get_data("user_data") + self.hide() + self.destroy() + gtk.main_quit() + + if ret == "Reboot": + os.system("sudo shutdown -r now") + if ret == "Suspend": + os.system("sudo pm-suspend") + if ret == "Halt": + os.system("sudo shutdown -h now") + +class ButtonBox(gtk.Window): + def __init__(self, parent=None): + # Create the toplevel window + gtk.Window.__init__(self) + try: + self.set_screen(parent.get_screen()) + except AttributeError: + self.connect('destroy', lambda *w: gtk.main_quit()) + + self.set_title("Shutdown") + self.set_decorated(False) + self.set_position(gtk.WIN_POS_CENTER) + + hbox = gtk.HBox() + hbox.set_border_width(10) + + self.add(hbox) + hbox.pack_start(create_bbox(None, 8, gtk.BUTTONBOX_START), + padding=0) + + self.show_all() + +def main(): + ButtonBox() + gtk.main() + +def register_iconsets(icon_info): + iconfactory = gtk.IconFactory() + stock_ids = gtk.stock_list_ids() + for stock_id, file in icon_info: + # only load image files when our stock_id is not present + if stock_id not in stock_ids: + pixbuf = gtk.gdk.pixbuf_new_from_file(file) + iconset = gtk.IconSet(pixbuf) + iconfactory.add(stock_id, iconset) + iconfactory.add_default() + +register_iconsets([('gnome-session-suspend', '/usr/share/icons/hydroxygen/128x128/apps/gnome-session-suspend.png'), + ('gnome-session-halt', '/usr/share/icons/hydroxygen/128x128/apps/gnome-session-halt.png'), + ('gnome-session-reboot', '/usr/share/icons/hydroxygen/128x128/apps/gnome-session-reboot.png') + ]) + + +if __name__ == '__main__': + main() diff --git a/python/shutdown.py.old b/python/shutdown.py.old new file mode 100644 index 0000000..0d3696d --- /dev/null +++ b/python/shutdown.py.old @@ -0,0 +1,88 @@ +#!/usr/bin/env python + +import sys +import getopt +import gtk + +class MessageBox(gtk.Dialog): + def __init__(self, message="", buttons=(), pixmap=None, + modal= True): + gtk.Dialog.__init__(self) + self.connect("destroy", self.quit) + self.connect("delete_event", self.quit) + if modal: + self.set_modal(True) + hbox = gtk.HBox(spacing=0) + hbox.set_border_width(0) + self.vbox.pack_start(hbox) + hbox.show() + if pixmap: + self.realize() + pixmap = Pixmap(self, pixmap) + hbox.pack_start(pixmap, expand=False) + pixmap.show() +# label = gtk.Label(message) +# hbox.pack_start(label) +# label.show() + for text in buttons: + b = gtk.Button(text) + b.set_flags(gtk.CAN_DEFAULT) + b.set_data("user_data", text) + b.connect("clicked", self.click) + self.action_area.pack_start(b) + b.show() + self.ret = None + def quit(self, *args): + self.hide() + self.destroy() + gtk.main_quit() + def click(self, button): + self.ret = button.get_data("user_data") + self.quit() + +# create a message box, and return which button was pressed +def message_box(title="Message Box", message="", buttons=(), pixmap=None, + modal= gtk.TRUE): + win = MessageBox(message, buttons, pixmap=pixmap, modal=modal) + win.set_title(title) + win.show() + gtk.main() + return win.ret + +def test(): + result = message_box(title='', + message='', + buttons=('Cancel', 'Reboot', 'Suspend', 'Halt')) + print 'result:', result + +USAGE_TEXT = """ +Usage: + python simple_dialog.py [options] +Options: + -h, --help Display this help message. +Example: + python simple_dialog.py +""" + +def usage(): + print USAGE_TEXT + sys.exit(-1) + +def main(): + args = sys.argv[1:] + try: + opts, args = getopt.getopt(args, 'h', ['help']) + except: + usage() + relink = 1 + for opt, val in opts: + if opt in ('-h', '--help'): + usage() + if len(args) != 0: + usage() + test() + +if __name__ == '__main__': + main() + #import pdb + #pdb.run('main()') diff --git a/screen-locker.sh b/screen-locker.sh index 68b587c..f14bd91 100755 --- a/screen-locker.sh +++ b/screen-locker.sh @@ -1,3 +1,12 @@ #!/bin/sh -slock & -(sleep 0.5 && swarp 0 0) & \ No newline at end of file +lock () { + gajim-remote change_status away & + slock +} + +unlock () { + gajim-remote change_status online & +} + +(lock && unlock) & +(sleep 0.5 && swarp 0 0) & diff --git a/set-background.sh b/set-background.sh index ea3e069..bce00f5 100755 --- a/set-background.sh +++ b/set-background.sh @@ -1,11 +1,11 @@ #!/bin/sh -#----------------------------------------------------# -# File: ~/bin/set-background.sh # -# Version: 0.1.1 # -# Date: 2008-10-6 # -# Author: Florian "Bluewind" Pritz # -# start screen with a combined config file # -#----------------------------------------------------# +#---------------------------------------------------- +# File: ~/bin/set-background.sh +# Version: 0.1.2 +# Date: 2009-01-18 +# Author: Florian "Bluewind" Pritz +# start screen with a combined config file +#---------------------------------------------------- # Usage: set-background.sh # Sets background using feh and creates symlink for slim #----------------------------------------------------# @@ -27,7 +27,7 @@ if [ "" = $DISPLAY ]; then fi if [ "$1" = "" ] || [ "$1" = "-h" ]; then - notify-send -t 10000 "Background" "Usage: set-background "; + notify-send -t 10000 "Background" "Usage: set-background <file>"; exit 1 fi -- cgit v1.2.3-24-g4f1b