SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2008-12-13 03:23:36

iggykoopa
Script Master
Registered: 2008-12-13
Posts: 1,480

updated openbox-logout script

I updated the logout script to include a suspend option and to have shortcut keys in case you dont want to use the mouse. The shortcut keys are alt + the underlined letter. Here it is if you want to use it:

#!/usr/bin/env python

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("gdm-control --reboot && openbox --exit")

    # Shutdown
    def shutdown(self, widget):
        os.system("gdm-control --shutdown && openbox --exit")
       
    # Suspend
    def suspend(self, widget):
        os.system("gdm-control --suspend")

    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 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_use_underline(True)
        self.button1.set_border_width(10)
        self.button1.connect("clicked", self.delete_event, "Changed me mind :)")
        self.box1.pack_start(self.button1, True, True, 0)
        self.button1.show()

        # Create logout button
        self.button2 = gtk.Button("_Log out")
        self.button2.set_use_underline(True)
        self.button2.set_border_width(10)
        self.button2.connect("clicked", self.logout)
        self.box1.pack_start(self.button2, True, True, 0)
        self.button2.show()

        # Create reboot button
        self.button3 = gtk.Button("_Reboot")
        self.button3.set_use_underline(True)
        self.button3.set_border_width(10)
        self.button3.connect("clicked", self.reboot)
        self.box1.pack_start(self.button3, True, True, 0)
        self.button3.show()

        # Create shutdown button
        self.button4 = gtk.Button("_Shutdown")
        self.button4.set_use_underline(True)
        self.button4.set_border_width(10)
        self.button4.connect("clicked", self.shutdown)
        self.box1.pack_start(self.button4, True, True, 0)
        self.button4.show()
       
        # Create suspend button
        self.button5 = gtk.Button("S_uspend")
        self.button5.set_use_underline(True)
        self.button5.set_border_width(10)
        self.button5.connect("clicked", self.suspend)
        self.box1.pack_start(self.button5, True, True, 0)
        self.button5.show()

        self.box1.show()
        self.window.show()

def main():
    gtk.main()

if __name__ == "__main__":
    gogogo = DoTheLogOut()
    main() 

I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Offline

Help fund CrunchBang, donate to the project!

#2 2008-12-13 03:49:02

corenominal
root
From: Lincoln, UK
Registered: 2008-11-20
Posts: 4,888
Website

Re: updated openbox-logout script

Hello iggykoopa smile

Thank you for taking the time to improve the script, it is really appreciated. I had a crack at it myself, adding suspend and hibernate options; however, for some unknown reason it did not occur to me to add shortcut keys. Doh! Would it be okay by you if I updated my scripts to include similar shortcuts?

P.S. Welcome to the forums, it is good to have you aboard!

Offline

#3 2008-12-13 04:04:53

iggykoopa
Script Master
Registered: 2008-12-13
Posts: 1,480

Re: updated openbox-logout script

no problem, a user on the wattos forums had requested it so I modified it for him. Figured I'd share it back with you. Thanks for your work on this excellent distro.


I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Offline

#4 2008-12-13 05:07:41

corenominal
root
From: Lincoln, UK
Registered: 2008-11-20
Posts: 4,888
Website

Re: updated openbox-logout script

Nice one, thank you for sharing. I have updated the packages to reflect your changes.

Offline

#5 2008-12-16 20:29:57

rizzo
#! wanderer
From: ~/
Registered: 2008-11-25
Posts: 5,109

Re: updated openbox-logout script

This is a great collaborative effort smile The alt key option is such a nice inclusion.

Offline

#6 2008-12-18 19:27:53

nipeng
#! Member
Registered: 2008-12-13
Posts: 57

Re: updated openbox-logout script

Aha this explains the unexpected dependency between the logout script and GDM.


---
I don't like peanuts.

Offline

#7 2008-12-22 21:29:00

ADcomp
Python Script Master
From: Belgium
Registered: 2008-12-22
Posts: 598
Website

Re: updated openbox-logout script

Hello .. ( sorry for my poor english )

I have similar script to logout .. But I use my wallpaper as background ( screen_width , screen_height ) with nice button

[1440x900]  http://www.ad-comp.be/public/openbox/op … esktop.jpg

.openbox_desktop_m.jpg

[1440x900]  http://www.ad-comp.be/public/openbox/openbox_logout.jpg

.openbox_logout_m.jpg

you can find it here : http://www.ad-comp.be/public/projets/my_exit.tar.bz2

Bye ..


David [aka] ADcomp

Offline

#8 2008-12-22 22:35:41

rizzo
#! wanderer
From: ~/
Registered: 2008-11-25
Posts: 5,109

Re: updated openbox-logout script

That is really nice. The beauty of openbox smile

Offline

#9 2008-12-23 03:40:10

iggykoopa
Script Master
Registered: 2008-12-13
Posts: 1,480

Re: updated openbox-logout script

if you guys want I could change the images to something similar for the existing logout script. I wouldn't be able to set the pseudo-transparent background though.


I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Offline

#10 2008-12-23 04:02:16

arpbook
The Mac Magician
From: montpellier,france
Registered: 2008-11-27
Posts: 177
Website

Re: updated openbox-logout script

@ADcomp, how did you do to put your volume-control on tray ?


arpbook is dead - arpinux is born, and became a deviant.

Offline

#11 2008-12-23 04:20:35

rizzo
#! wanderer
From: ~/
Registered: 2008-11-25
Posts: 5,109

Re: updated openbox-logout script

iggykoopa wrote:

if you guys want I could change the images to something similar for the existing logout script.

I like your script just the way it is smile

Offline

#12 2008-12-23 04:25:34

ADcomp
Python Script Master
From: Belgium
Registered: 2008-12-22
Posts: 598
Website

Re: updated openbox-logout script

arpbook wrote:

@ADcomp, how did you do to put your volume-control on tray ?

Hello .. http://oliwer.net/b/volwheel.html    big_smile

depend : libgtk2-perl ,  libgtk2-trayicon-perl   ..

sudo apt-get install libgtk2-perl  libgtk2-trayicon-perl

Just a little perl script .. I found same in python but volwheel is better

Bye

Last edited by ADcomp (2008-12-23 04:27:47)


David [aka] ADcomp

Offline

#13 2008-12-23 04:33:05

iggykoopa
Script Master
Registered: 2008-12-13
Posts: 1,480

Re: updated openbox-logout script

for volume control you could look into this http://oliwer.net/b/volwheel.html
edit: lol I was too slow with that one.

Last edited by iggykoopa (2008-12-23 04:33:38)


I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Offline

#14 2008-12-23 04:56:50

arpbook
The Mac Magician
From: montpellier,france
Registered: 2008-11-27
Posts: 177
Website

Re: updated openbox-logout script

thanks both big_smile
hey cool !! we can change the icon smile

Last edited by arpbook (2008-12-23 04:58:09)


arpbook is dead - arpinux is born, and became a deviant.

Offline

#15 2009-01-10 08:40:19

cdn
Member
From: Liverpool, UK
Registered: 2009-01-10
Posts: 11

Re: updated openbox-logout script

Really impressed with ADComp's logout script.

I created a bash script to wrap around it and imagemagick. smile This script snaps the current screen and blurs it, like the GDM logout does.
You could tweak the options in ImageMagick to get just the right effect aswell.

I used scrot for the actual snapshot because I wasn't going to use IM at all at first until I realised I could do with a blur. I'm too tired right now to bother looking up the syntax for screenshots within IM, so, this script will have to remain hackish by using two separate imaging tools.

You might like to remove the convert line for speed, as on my machine at least it's rather slow (a full six (6)! seconds before logout menu is displayed).

I would like to hack this further to support Hibernate and Suspend, too.

#!/bin/sh

scrot -q 50 /home/chris/Junk/my_exit/img/bg.jpg
convert /home/chris/Junk/my_exit/img/bg.jpg -blur 0x3 /home/chris/Junk/my_exit/img/bg.jpg
cd /home/chris/Junk/my_exit
./my_exit.py

Last edited by cdn (2009-01-10 08:45:43)

Offline

#16 2009-01-11 04:47:14

iggykoopa
Script Master
Registered: 2008-12-13
Posts: 1,480

Re: updated openbox-logout script

here's a copy of the my_exit.py that's been patched to do the same thing http://www.crunchbanglinux.org/pastebin/73 . Hopefully it'll run a little faster for you since it doesn't use any external commands to take the screenshot and do the blur. If you can get me some icons you want to use for the suspend and hibernate I can add that in, but I'm not very graphically inclined.

edit: the only problem I had with it is the method I used to blur it isn't very configurable, so if you don't like the blur effect it gives it I may have to look into another method.

edit again: if it still runs too slow for you change line 56 to

for i in range(1):

the blur won't look as nice but it will run a lot faster.

Last edited by iggykoopa (2009-01-11 04:54:43)


I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Offline

#17 2009-01-11 06:29:46

cdn
Member
From: Liverpool, UK
Registered: 2009-01-10
Posts: 11

Re: updated openbox-logout script

Thanks, that makes it twice as quick! smile

I'll see if I can find some SVG icons and add the elements for the hibernate and suspend commands. Just as soon as I find out what they are.

Offline

#18 2009-01-11 15:21:23

ADcomp
Python Script Master
From: Belgium
Registered: 2008-12-22
Posts: 598
Website

Re: updated openbox-logout script

Hello .. nice work big_smile

If you just want  somethink like gnome/gdm logout ( gray ? ) , replace line 56-57

            for i in range(2):
                image = image.filter(ImageFilter.BLUR)

here you can modify color ( black , red , blue , green or #333333 ...) and alpha  ( 0 --> 1 )

            color = 'black'
            alpha = 0.5
            mask = Image.new("RGB", image.size, color)
            image = Image.blend(image, mask, alpha)

Bye ..

Last edited by ADcomp (2009-01-11 15:25:35)


David [aka] ADcomp

Offline

#19 2009-01-11 16:55:10

ADcomp
Python Script Master
From: Belgium
Registered: 2008-12-22
Posts: 598
Website

Re: updated openbox-logout script

Hello ..

Add hibernate / suspend  button ( but no command ) and blend image with color .. clean little bit code too   wink
I'm working on panel configuration ( like adeskbar ) ..

Code : http://www.ad-comp.be/public/projets/My … it.tar.bz2

Screenshot : http://www.ad-comp.be/public/projets/My … it_new.jpg

.My_Exit_new_m.jpg

Bye ..


> Edit [1] :  icon from Oxygen icon pack ( kde )

> Edit [2] :  I don't know command for hibernate/suspend but I think you can find useful info looking for gnome-power-manager and acpi
http://live.gnome.org/GnomePowerManager/FAQ
http://manpages.ubuntu.com/manpages/har … onf.5.html
https://help.ubuntu.com/community/SuspendHowto

Last edited by ADcomp (2009-01-11 19:05:26)


David [aka] ADcomp

Offline

#20 2009-01-11 17:53:52

iggykoopa
Script Master
Registered: 2008-12-13
Posts: 1,480

Re: updated openbox-logout script

the code for suspend and hibernate is in the openbox-logout-script I don't have a copy right now cause I'm running the netbook remix. If I get ahold of it I can add it in, or if you have it it's there.


I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Offline

#21 2009-01-11 18:02:24

rizzo
#! wanderer
From: ~/
Registered: 2008-11-25
Posts: 5,109

Re: updated openbox-logout script

    # Hibernate
    def hibernate(self, widget):
        os.system("(sleep 1s && gnome-power-cmd.sh hibernate) && killall python /usr/bin/openbox-logout")

    # Suspend
    def suspend(self, widget):
        os.system("(sleep 1s && gnome-power-cmd.sh suspend) && killall python /usr/bin/openbox-logout")

Offline

#22 2009-01-11 18:53:31

Nik_Doof
#! Junkie
Registered: 2008-12-13
Posts: 361
Website

Re: updated openbox-logout script

Can we get this code in a bzr repo? I'd like to make the script have a bit more detection (like checking the device can suspend/resume), also it would be nice to switch between graphical and button mode smile

Maybe its a idea to start working on a few project in house, instead of the mishmash of code and hacks we're getting at the moment. Maybe some #! packages of our own for the extra stuff we need.

Last edited by Nik_Doof (2009-01-11 18:55:29)

Offline

#23 2009-01-11 19:29:22

iggykoopa
Script Master
Registered: 2008-12-13
Posts: 1,480

Re: updated openbox-logout script

added suspend and hibernate now here http://www.crunchbanglinux.org/pastebin/74 . I know suspend works but not sure on hibernate since I don't have a big enough swap right now on my mini.


I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Offline

#24 2009-01-11 19:54:26

ADcomp
Python Script Master
From: Belgium
Registered: 2008-12-22
Posts: 598
Website

Re: updated openbox-logout script

@ iggykoopa .. I have a question. Why do you use kill ?

            pid = os.getpid()
            os.system("(sleep 1s && gnome-power-cmd.sh suspend) && kill " + str(pid))

This doesn't work ?

            os.system("(sleep 1s && gnome-power-cmd.sh suspend) &")
            self.doquit()
Nik_Doof wrote:

Can we get this code in a bzr repo? I'd like to make the script have a bit more detection (like checking the device can suspend/resume), also it would be nice to switch between graphical and button mode smile

no repo yet (.. at least for me ).  maybe I can create one on launchpad if you want ..  wait & see

Bye big_smile


David [aka] ADcomp

Offline

Be excellent to each other!

#25 2009-01-11 21:00:32

iggykoopa
Script Master
Registered: 2008-12-13
Posts: 1,480

Re: updated openbox-logout script

I was just using it because the original script did. I can test if it works without it.


I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo