You are not logged in.
I got openbox+slim working great on a testing machine. The only problem is is that I have to drop to console to shutdown or reboot the computer. How would I set up restarting/shutdown without having to drop to the shell?
Offline
I use this script.
#!/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("sudo shutdown -r now && openbox --exit")
# Shutdown
def shutdown(self, widget):
os.system("sudo shutdown -h now && 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 logout button
self.button2 = gtk.Button("Log out")
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_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_border_width(10)
self.button4.connect("clicked", self.shutdown)
self.box1.pack_start(self.button4, True, True, 0)
self.button4.show()
self.box1.show()
self.window.show()
def main():
gtk.main()
if __name__ == "__main__":
gogogo = DoTheLogOut()
main()
Also I edited the sudoers file so I could run shutdown without password:
%wheel ALL=(ALL) NOPASSWD: /sbin/shutdown
Last edited by anonymous_user (2009-11-11 16:55:51)
Offline
Try oblogout is in AUR, works fine for me.
Website: andrwe.org
Offline
I'll give your python script a try. Thanks.
Offline
i used to use the following when i ran openbox. it's in bash and has the added bonus of gracefully closing all running apps before logout/shutdown/reboot - ing. requires zenity, wmctrl, and the NOPASSWD sudoers entry for shutdown.
#!/bin/bash
#
# a simple logout script which gracefully
# closes all apps before executing
#
###
message() {
echo "usage: leave [option]"
echo
echo " options:"
echo " -e logout / kill X"
echo " -r reboot system"
echo " -s shutdown system"
echo
exit 1
}
case $1 in
-e) LABEL="logout" ; [ -z "$DISPLAY" ] && ACTION="logout" || ACTION="kill $(pgrep X)" ;;
-r) LABEL="restart" ; ACTION="sudo /sbin/shutdown -r now" ;;
-s) LABEL="shutdown"; ACTION="sudo /sbin/shutdown -h now" ;;
*) message ;;
esac
# no X?
if [ -z "$DISPLAY" ]; then
echo -n "system will $LABEL in 3... "
sleep 1 && echo -n "2... "
sleep 1 && echo "1... "
sleep 1 && $ACTION &
exit 0
fi
# are you sure?
if zenity --question \
--title=$LABEL \
--ok-label=$LABEL \
--text="are you sure you want to $LABEL?"; then
# gracefully close all apps
wmctrl -l | awk '{print $1}' | while read APP; do
wmctrl -i -c $APP || echo "$APP not killed"
done
# do it
$ACTION &
exit 0
fi
# if we're still here, fail
exit 1
note: killing X is 'logging out' for me as i `startx; logout` conditionally from bashrc.
//github/
Offline
I was using an approach similar to brisbin33's employing dbus:
#!/bin/bash
RESULT=$(zenity --list --title "Exit" --text "Choose one:" \
--radiolist --column "" --column "Type" --column "Value" \
--hide-column=3 --print-column=3 \
TRUE Logout 0 FALSE Reboot 1 FALSE Shutdown 2)
if [[ -z $RESULT ]]; then
echo "empty";
exit 0;
fi
if (( $RESULT == 0 )); then
openbox --exit;
elif (( $RESULT == 1 )); then
$(dbus-send --system --print-reply \
--dest="org.freedesktop.Hal" \
/org/freedesktop/Hal/devices/computer \
org.freedesktop.Hal.Device.SystemPowerManagement.Reboot) && openbox --exit;
elif (( $RESULT == 2 )); then
$(dbus-send --system --print-reply \
--dest="org.freedesktop.Hal" \
/org/freedesktop/Hal/devices/computer \
org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown) && openbox --exit;
fi
This requires you to start your Openbox session with
exec ck-launch-session openbox-session
Nowadays I'm using xdm with my own theme (AUR) which has shutdown / reboot buttons.
Offline
aur -> shutdown-dialog.py
Offline
In my OpenBox menu I have the following menu:
<menu id="root-menu-34513" label="Exit">
<item label="Halt">
<action name="Execute">
<execute>
sudo halt
</execute>
</action>
</item>
<item label="Reboot">
<action name="Execute">
<execute>
sudo reboot
</execute>
</action>
</item>
<item label="Logout">
<action name="Execute">
<execute>
openbox --exit
</execute>
</action>
</item>
<item label="Suspend">
<action name="Execute">
<execute>
sudo pm-suspend
</execute>
</action>
</item>
<item label="Hibernate">
<action name="Execute">
<execute>
sudo pm-hibernate
</execute>
</action>
</item>
</menu>
Don't know if it's the rigth way to do it, but it works for me.
Arch x86_64 on HP 6820s and on HP nx9420. Registered Linux User 350155, since 24-03-2004
"Everyone said that it could not be done, until someone came along who didn't know that."
Offline
I made this submenu for shuting down my pc
<menu id="end" label="End">
<item label="exit">
<action name="exit">
</action>
</item>
<item label="restart">
<action name="execute">
<command>aterm -e sudo shutdown -r now</command>
</action>
</item>
<item label="shutdown">
<action name="execute">
<command>aterm -e sudo shutdown -h now</command>
</action>
</item>
</menu>
Last edited by singral (2009-11-11 21:55:35)
Offline
When using the sudo in the menu, does'nt it want a password?
[ logicspot.NET | mempad.org ]
Archlinux x64
Offline
^ not if you change the sudoers file.
Offline
After the current consolekit 0.4.1-2 update shutdown -r/-h now is not working thro' script or thro' keybindings. tho' sudoers got ALL =(ALL) NOPASSWD,/sbin/shutdown. But halt and reboot works as intended. the_isz method of using dbus works fine. This is for the records.
Offline
I updated consolekit and the script I posted still works fine for me.
Offline
The problem is in using bash script or a direct keybinding for shutdown command mentioned in post #12.
Offline
I use a menu dialog, make with zenity, look like this:
# Filename: logout.sh
# Purpose: Simple logout script using zenity
# Authors: OU812 and anticapitalista for antiX
# Latest change: Sun April 13, 2009.
################################################################################
#!/bin/sh
ans=$(zenity --width=40 --height=200 --title="Salir" --list --text "¿Qué deseas hacer?" --radiolist --column "Elige" --column "Acción" TRUE Logout FALSE Reiniciar FALSE Apagar); #echo $ans
if [ "$ans" = "Logout" ] ; then
kill -TERM $(xprop -root _BLACKBOX_PID | awk '{print $3}')
fi
if [ "$ans" = "Reiniciar" ]; then
sudo reboot
fi
if [ "$ans" = "Apagar" ]; then
sudo halt
fi
change permission and copy to /usr/bin, and add a openbox menu entry for this script.
and also I edited the sudoers:
your_user ALL=(ALL) NOPASSWD:/sbin/shutdown
your_user ALL=(ALL) NOPASSWD:/sbin/halt
your_user ALL=(ALL) NOPASSWD:/sbin/reboot
You need install zenitiy libraries and thar's all.
"Yo creo que los muertos son tiernos. ¿Nos besamos?"
Offline
I took some things from here(brisbin33) and there(the_isz) and else(?) and built "pancakes":
http://github.com/JesusSuperstar/dotfil … s/pancakes
#!/bin/bash
#
# A script to gracefully shutdown openbox, closing all apps
# without the need to have extra permissions, or sudo entries
# plus an optional timeout in secs, min, hours or days
# The script depends on HAL, D-bus and wmctrl
# the usage message
usage() {
echo "Usage is: $0 OPTION [TIME]"
echo
echo " Option:"
echo " -h halt, poweroff"
echo " -r reboot"
echo
echo " Time:"
echo " NUMBER[SUFFIX]"
echo " Suffix is \"s\" for seconds"
echo " \"m\" for minutes"
echo " \"h\" for hours"
echo " \"d\" for days"
exit 1
}
# our local vars
action="$1"
time="${2:-0}" #default timeout is now
# check for correct form of arguments
if [[ -z "$action" || ! $time =~ ^[[:digit:]]+[s|m|h|d]?$ ]]; then
usage
fi
# gracefully close all apps
close_apps(){
wmctrl -l | awk '{print $1}' | while read APP; do
wmctrl -i -c $APP || echo "$APP not killed"
done
}
# shutdown
shut(){
dbus-send --system --print-reply \
--dest="org.freedesktop.Hal" \
/org/freedesktop/Hal/devices/computer \
org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown
}
# reboot
rebt(){
dbus-send --system --print-reply \
--dest="org.freedesktop.Hal" \
/org/freedesktop/Hal/devices/computer \
org.freedesktop.Hal.Device.SystemPowerManagement.Reboot
}
# do it
case $action in
-r) sleep +"$time" && close_apps && rebt && openbox --exit ;;
-h) sleep +"$time" && close_apps && shut && openbox --exit ;;
*) usage ;;
esac
Last edited by JesusSuperstar (2010-01-05 17:37:43)
.:[dotfiles]:.
Offline
Once I have build a nice dialog with ruby and gtk, but
chmod +s /sbin/halt
and adding a line for "halt" and for "reboot" in your OpenboxMenu should be enough. Or am I wrong?
Last edited by muunleit (2010-01-05 21:11:43)
"The mind can make a heaven out of hell or a hell out of heaven" -- John Milton
Offline
Maybe I am the only one that doesn't actually like there being an option to shutdown/restart without being root. Last thing i want is someone to use my computer and click that on accident. Least this way i am able to control the system that way.
Linux ArchLinux 3.2.8-1-ARCH
#1 SMP PREEMPT Mon Feb 27 21:51:46 CET 2012 x86_64 AMD FX(tm)-8120 Eight-Core Processor AuthenticAMD GNU/Linux
8192MB DDR3 1300MHz | Asus m5a97 | GeForce GTX 550 Ti | 120 GB SSD
Offline
I'm trying to do this as well. I got my entries in .config/openbox/menu.xml, and have done the sudo entries as well but for some reason when I do openbox --reconfigure or openbox --restart or even reboot the computer my new entries refuse to show up in the openbox menu. Any ideas of what I might be doing wrong? I am not familiar with editing xml files.. I removed all the tabs in the menu.xml file as I thought that was kind of annoying, think that might be it? I'm also not very good with vi, still learning.
<separator/>
<item label="exit">
<action name="Exit"/>
</item>
</menu>
<item label="reboot">
<action name="Execute">
<command>sudo reboot</command>
</action>
</item>
<item label="shutdown">
<action name="Execute">
<command>sudo shutdown -h now</command>
</action>
</item>
Cmnd_Alias SHUTDOWN_CMDS = /sbin/reboot*, /sbin/shutdown*, /sbin/halt*
Offline
This may not be the exact answer to your question, but if you use SLIM, then you can logout from Openbox and then type 'halt' or 'reboot' in the SLIM login prompt, followed by root password. This is not-so-obvious feature of SLIM.
Offline
wall of text
I would use upower/consolekit or similar instead of sudo shutdown.
You can do something like:
halt:
dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
reboot:
dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart
suspend:
dbus-send --system --print-reply --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend
hibernate:
dbus-send --system --print-reply --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Hibernate
Edit;
See http://www.freedesktop.org/software/Con … ml#Manager and http://upower.freedesktop.org/docs/UPower.html for details.
Last edited by Mr.Elendig (2010-10-27 15:09:00)
Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest
Offline
@Stowlowsky
Already tries slim manager, I don't like it. I prefer plain old console which is weird cuz I'm so new to CLI. I knew about the shutdown reboot items from within the login screen, reboot and shutdown would work ok but not console which was enough for me to ditch it. To me slim is just another thing that gets in the way.
@Mr.Elendig
Thanks for suggesting a more graceful way to do things. I replaced my entries with your examples. All for naught until the entries show up in the menu though .
@ all
I changed the <command> tags to <execute> but still nothing. Also tried commenting out one entry to see if there might be a limit to how many entries can be at the top level of the menu. I used # but apparently it's more like html with the <!-- --> form of commenting. Hid one entry but the new entries still refuse to show up.
Am reading up on the openbox documentation on the syntax.. Sorry for not doing this before.
Last edited by adamlogan (2010-10-27 21:48:22)
Offline
Have tried moving the line "</menu>" to the end yet?
Offline
@ skunktrader
Thanks. So embarrassed I can't believe I didn't see/look for that. I just assumed I had made new entries before the </menu> tag, I'm not used to copy/paste and vi in general.
Edit:
Suspend and Hibernate don't do anything for me. Any idea how I could get those to work? Not a huge deal but it'd be nice to have the functionality if I need it.
Is there a way to exit openbox to console without the promt asking whether or not I really want to exit openbox.
Last edited by adamlogan (2010-10-27 23:16:55)
Offline
Is there a way to exit openbox to console without the promt asking whether or not I really want to exit openbox.
From my menu.xml:
</item>
<item label=" exit openbox ">
<action name="Exit">
<prompt>
yes
</prompt>
</action>
</item>
Change "yes" to "no".
The indentations are there to make it easier to spot mistakes.
Offline