You are not logged in.
if you encounter problems please tell me here
so far 1 person has a problem with the old script
update: Feb 13
------------------------------------------------
------------------------------------------------
it always bothered me that the openbox-logout-script-basic script never had a suspend button (and who uses that?) and the openbox-logout-script acted kind of strange when pressing the suspend and hibernate buttons so i decided to check the script out myself
now it has a nothing-strange-working suspend button

just
gksu gedit /usr/bin/openbox-logoutand replace that code with this
(you can back up your old code first but it's not really necessary since the openbox-logout-script and openbox-logout-script-basic are both in the repos)
#!/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
# Suspend
def suspend(self, widget):
os.system("dbus-send --session --dest=org.freedesktop.PowerManagement --type=method_call /org/freedesktop/PowerManagement org.freedesktop.PowerManagement.Suspend")
# 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")
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_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 suspend button
self.button2 = gtk.Button("S_uspend")
self.button2.set_border_width(10)
self.button2.connect("clicked", self.suspend)
self.button2.connect("clicked", self.delete_event, "Force removal :(")
self.box1.pack_start(self.button2, True, True, 0)
self.button2.show()
# Create logout button
self.button3 = gtk.Button("_Log out")
self.button3.set_border_width(10)
self.button3.connect("clicked", self.logout)
self.box1.pack_start(self.button3, True, True, 0)
self.button3.show()
# Create reboot button
self.button4 = gtk.Button("_Reboot")
self.button4.set_border_width(10)
self.button4.connect("clicked", self.reboot)
self.box1.pack_start(self.button4, True, True, 0)
self.button4.show()
# Create shutdown button
self.button5 = gtk.Button("_Shutdown")
self.button5.set_border_width(10)
self.button5.connect("clicked", self.shutdown)
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()Last edited by ali (2011-02-13 20:17:47)
Offline
Nice, I will try and check this out. Also, I think these scripts will need updating soon as I am not sure if 'gdm-control' will be supported in the future. 
Offline
well, you could use dbus to shutdown and reboot as well, it'll work but not as smooth and clean as gdm-control
Last edited by ali (2011-02-09 10:18:50)
Offline
Great post thanks.
I needed this today but didn't know how to do it. Now I do.
Cheers,
AX
Offline
Offline
@ali, I am having trouble with shutdown when using both the openbox-logout-script-basic script and the openbox-logout-script. You mention using dbus as a replacement. Can you explain exactly how this is done? Thanks!
"Don't you draw the queen of diamonds, boy, she'll beat you if she's able. You know the queen of hearts is always your best bet."
- Glenn Frey & Don Henley
Offline
replace the text from inside the single quotes on line 29 (make sure not to ruin the indentation since python is very strict on that
replace
os.system("gdm-control --shutdown && openbox --exit")
to
os.system("dbus-send --print-reply --system --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown")
but that won't display the services shutting down UNLESS you're in a tty
maybe corenominal or someone who has some experience with linux can help us figure out how to get to a tty that would be so cool
(what command is executed when pressing C-A-F1!?)
once you figure that out it's really easy
Last edited by ali (2011-02-10 06:27:50)
Offline
@ali, I made the changes by following your excellent instructions and I am happy to report the problem is solved, success achieved! Your help is greatly appreciated. 
"Don't you draw the queen of diamonds, boy, she'll beat you if she's able. You know the queen of hearts is always your best bet."
- Glenn Frey & Don Henley
Offline
glad your problem was solved 
Last edited by ali (2011-02-10 20:44:41)
Offline
Hello Ali,
On my system, your code for suspend sems to do nothing :
os.system("dbus-send --session --dest=org.freedesktop.PowerManagement --type=method_call /org/freedesktop/PowerManagement org.freedesktop.PowerManagement.Suspend")
This one is running well :
os.system("dbus-send --print-reply --system --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Suspend int32:0"). 
Offline
good to know
#! ~/ $ lshal | grep power_management.can
power_management.can_hibernate = true (bool)
power_management.can_suspend = true (bool)
power_management.can_suspend_hybrid = true (bool)
looks like hal works on my machine too, maybe i'll start using that instead
Last edited by ali (2011-02-13 06:13:13)
Offline
new openbox-logout:

what has changed?
- added hibernate button
- dbus signals handled by hal now 
- changed key shortcuts to alt + 1...6 (makes my life easier, the syntax is simple if you want to change it back
)
#!/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
# Suspend
def suspend(self, widget):
os.system("kill `ps -ef | grep /usr/bin/openbox-logout | grep -v grep | awk '{print $2}'` && dbus-send --system --print-reply --dest=\"org.freedesktop.Hal\" /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Suspend int32:0")
# hibernate
def hibernate(self, widget):
gtk.main_quit()
os.system("kill `ps -ef | grep /usr/bin/openbox-logout | grep -v grep | awk '{print $2}'` && dbus-send --system --print-reply --dest=\"org.freedesktop.Hal\" /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Hibernate")
# 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")
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("_1. Cancel")
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 suspend button
self.button2 = gtk.Button("_2. Suspend")
self.button2.set_border_width(10)
self.button2.connect("clicked", self.suspend)
self.box1.pack_start(self.button2, True, True, 0)
self.button2.show()
# Create hibernate button
self.button3 = gtk.Button("_3. Hibernate")
self.button3.set_border_width(10)
self.button3.connect("clicked", self.hibernate)
self.box1.pack_start(self.button3, True, True, 0)
self.button3.show()
# Create logout button
self.button4 = gtk.Button("_4. Log out")
self.button4.set_border_width(10)
self.button4.connect("clicked", self.logout)
self.box1.pack_start(self.button4, True, True, 0)
self.button4.show()
# Create reboot button
self.button5 = gtk.Button("_5. Reboot")
self.button5.set_border_width(10)
self.button5.connect("clicked", self.reboot)
self.box1.pack_start(self.button5, True, True, 0)
self.button5.show()
# Create shutdown button
self.button6 = gtk.Button("_6. Shutdown")
self.button6.set_border_width(10)
self.button6.connect("clicked", self.shutdown)
self.box1.pack_start(self.button6, True, True, 0)
self.button6.show()
self.box1.show()
self.window.show()
def main():
gtk.main()
if __name__ == "__main__":
gogogo = DoTheLogOut()
main()you may notice i killed the process prematurely, since it kills only the process /usr/bin/openbox-logout, it's safe (it only runs if /usr/bin/openbox-logout is running, if you run the script from another location it wont run)
------------------------------------
if you don't mind the delay change or simply want to keep it clean
change
os.system("kill `ps -ef | grep /usr/bin/openbox-logout | grep -v grep | awk '{print $2}'` && dbus-send --system --print-reply --dest=\"org.freedesktop.Hal\" /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Suspend int32:0")
os.system("kill `ps -ef | grep /usr/bin/openbox-logout | grep -v grep | awk '{print $2}'` && dbus-send --system --print-reply --dest=\"org.freedesktop.Hal\" /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Hibernate")to
os.system("dbus-send --system --print-reply --dest=\"org.freedesktop.Hal\" /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Suspend int32:0")
os.system("dbus-send --system --print-reply --dest=\"org.freedesktop.Hal\" /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Hibernate")and add anywhere in __init__ after button 2 && 3 were initialized
self.button3.connect("clicked", self.delete_event, "")
self.button2.connect("clicked", self.delete_event, "")Last edited by ali (2011-02-13 10:55:56)
Offline
When I shutdown or reboot, I get a high resolution "shutdown" or "reboot". I like it and would like something like "CrunchBang linux loading" as a bootsplash. And no progressbar or "loading, please wait"
Offline
i dont really understand what you're asking me
Offline
@Sveep - if you want to a make a feature request, please post here instead:
Note: ** Please read before posting **
BTW if you wish to contact me, send me an e-mail instead of a PM.
Offline
Hi!
Nice script. but hibernate doesn't work for me. The only thing I notice is, that my network connection gets killed and established again.
When starting the script from terminal with sudo I am getting following response:
~$ method return sender=:1.0 -> dest=:1.95 reply_serial=2
int32 128Without sudo I don't have permission to kill stuff.
Would be glad if you could help me with that, because I really like hibernation.
Offline
make sure you have enough swap space and that it's mounted (as i think that when you hibernate your ram memory is transfered to swap)
hibernate always fails as far as i know if swap is not mounted
execute this script
see if any of them work and come back to tell me
needless to say, make sure you save all your files in case the pc shuts down instead of hibernates
(after executing a command, you can't execute another until you close the terminal that automatically opens if it works)
#!/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
# Hal
def hal(self, widget):
os.system("terminator --command=\"dbus-send --system --print-reply --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Hibernate && sleep \"")
# DeviceKit
def dk(self, widget):
os.system("terminator --command=\"dbus-send --print-reply --system --dest=org.freedesktop.DeviceKit.Power /org/freedesktop/DeviceKit/Power org.freedesktop.DeviceKit.Power.Hibernate && sleep \"")
# UPower
def upower(self, widget):
os.system("terminator --command=\"dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Hibernate && sleep 20s\"")
# PowerManagement
def pm(self, widget):
os.system("terminator --command=\"dbus-send --session --dest=org.freedesktop.PowerManagement --type=method_call /org/freedesktop/PowerManagement org.freedesktop.PowerManagement.Hibernate && sleep 20s\"")
# gnome.PowerManager
def gpm(self, widget):
os.system("terminator --command=\"dbus-send --session --dest=org.gnome.PowerManager --type=method_call --print-reply --reply-timeout=2000 /org/gnome/PowerManager org.gnome.PowerManager.Hibernate && sleep 20s\"")
def __init__(self):
# Create a new window
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_title("which one?")
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 hal button
self.button2 = gtk.Button("Hal")
self.button2.set_border_width(10)
self.button2.connect("clicked", self.hal)
self.box1.pack_start(self.button2, True, True, 0)
self.button2.show()
# Create devicekit button
self.button3 = gtk.Button("DeviceKit")
self.button3.set_border_width(10)
self.button3.connect("clicked", self.dk)
self.box1.pack_start(self.button3, True, True, 0)
self.button3.show()
# Create upower button
self.button4 = gtk.Button("Upower")
self.button4.set_border_width(10)
self.button4.connect("clicked", self.upower)
self.box1.pack_start(self.button4, True, True, 0)
self.button4.show()
# Create PowerManagement button
self.button5 = gtk.Button("PowerManagement")
self.button5.set_border_width(10)
self.button5.connect("clicked", self.pm)
self.box1.pack_start(self.button5, True, True, 0)
self.button5.show()
# Create g.PowerManagement button
self.button6 = gtk.Button("g.PowerManagement")
self.button6.set_border_width(10)
self.button6.connect("clicked", self.gpm)
self.box1.pack_start(self.button6, True, True, 0)
self.button6.show()
self.box1.show()
self.window.show()
def main():
gtk.main()
if __name__ == "__main__":
gogogo = DoTheLogOut()
main()my outcome was:
Hal - works
DeviceKit - nothing happens
UPower - works
PowerManagement - works
gnome.PowerManagement - nothing happens
Last edited by ali (2011-02-15 07:16:31)
Offline
Thanks for the quick reply.
My swap partition is 1.5 times the size of my ram (Ram: 2 GB, Swap: 2.93 according to gparted) and mounted (checked with fdisk -l). I'm not sure if that's enough for hal etc., but since my ram never holds more than 700 MB of data it should be. When trying you script there were only 230 MB in ram. Swap is hardly ever used.
my outcome:
Hal - network connection restarts and that's it
DeviceKit - nothing
UPower - nothing
PowerManagement - locks screen, restarts network connection and wants my password to keep working. no hibernation though
gnome.PowerManagement - nothing (not installed I think)
I modified your script a little (removed the extra instance of terminator) to get the responses in command line:
DeviceKit, UPower and gnomePowerManagement were not provided by any service. So they seem not to be installed or running.
Will try installing gnome Powermanagement and see what that does.
Edit:
Just did that:
Error org.freedesktop.DBus.Error.UnknownMethod: Method "Hibernate" with signature "" on interface "org.gnome.PowerManager" doesn't existwhen running without new terminator window. Else nothing happens.
Last edited by Criminal (2011-02-15 09:21:44)
Offline
that's really strange...
what about
gksu pm-hibernateOffline
also i noticed there's a hibernate package in the repositories
try installing and running it if everything else fails
~/ $ sudo aptitude search hibernate
p hibernate - smartly puts your computer to sleep (suspend to RAM or disk)
[...]
~/ $ Offline
The same like hal: network gets shut down and reconnects.
I tried a way larger swap partition for testing as well. No change.
Could there be a hardware issue?
By the way: output of
lshal | grep power_management.canis true for all three instances
Offline
i hope not, try the hibernate package
sudo aptitude install hibernatethen
hibernateand if that doesn't work try
hibernate --forceLast edited by ali (2011-02-15 09:49:19)
Offline
tried that and it seems to be a push in the right direction.
When running either hibernate or hibernate --force I get following error:
hibernate:Warning: Tuxonice binary signature file not found.
You haven't specified a resume=/resume2= parameter on your kernel command line
Your GRUB or LILO config should have something like resume=swap:/dev/hdaX
where /dev/hdaX is your swap partition. You will then need to either reboot
after doing so or set it manually (this time only) using:
echo swap:/dev/hdaX > /sys/power/tuxonice/resume
hibernate: Aborting.
ERROR: Module tuxonice_core is in use by tuxonice_bioI added the line
resume=swap:/dev/sda1at the end of my grub.cfg and rebooted, but no change. Seems like I'm missing a step. Do you have an idea?
I'll be away for some hours now. Will report back later.
Thanks for your help! I really appreciate that.
Offline
no idea, you swap is on /dev/sda1?
Offline
swap is on /dev/sda1.
I had to put the entry to the end of the linux line in grub.cfg.
Laptop goes down for hibernation and hibernation.log looks good as well. But it doesn't wake up again. Booting stops at the time when normaly the gdm screen would appear or - when hibernating - my desktop should show. It freezes for a short time and then reboots without hibernating.
kern.log says that tuxonice is not running yet, but I can't remember having installed that one. Isn't that a kernel patch?
Offline
Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.