You are not logged in.

Announcement

Due to heavy spamming of forums registration is going in stages. If you wish to register as a new user with ArchBang Forums, first register and then send an e-mail to: archbangforums at gmail dot com. It should contain the problem you want to discuss or some other AB related content. You will be promoted from registering member with no posting rights to new member with posting rights after that. If your mail is ignored you haven't fulfilled the requirements.

#1 2011-02-03 09:24:53

xunil
Member
Registered: 2011-02-03
Posts: 26

Zenity shutdown, reboot,logout script.

Hi, I found this good script on a blog it's a shutdown,reboot,logout for openbox.
It doesn't use gdm and hal, but you need to download Zenity from pacman.
Name it exit.sh and make it executable, put it in user/bin and edit the menu.xml ad a line exit.sh
I hope it helps someone.

2unytjd.png


#!/bin/bash
# Multiple Exit Script using Zenity for non GDM installs
# Requires zenity and an edit to sudoers to allow all users to use the shutdown command
# As follows:
#
# Open a terminal
# EDITOR=nano
# sudo visudo
# Scroll to bottom of file and add this: (not the #)
# ALL ALL=NOPASSWD:/sbin/shutdown
# 
######## This part is the Exit Type picker  ##########

title="EXIT: What do you want to do ?"
exit_type=`zenity  --width="530" --height="220" --title="$title" --list --radiolist --column="Click Here" \
    --column="Exit Type" --column="Description" \
    TRUE "Logout" "Log Current User out and return to Login Screen"\
    FALSE "Reboot" "Reboot the PC"\
    FALSE "Shutdown" "Shutdown the PC"\
    FALSE "Cancel" "Cancel the Exit" \
    | sed 's/ max//g' `

echo "$exit_type chosen as the Exit Type!."

#user must select a target type (Check if they cancelled)
if [ ! "$exit_type" ]; then
    zenity --error --title="Error" --text="You must make a selection!"
    exit
fi

######### This part takes the selection and applies it!  #############

# Edit this first section if not using openbox! #
if [ "$exit_type" = "Logout" ]
then
        # Do logout here.
        openbox --exit && sleep 1 | zenity --progress --percentage=95 --title=Logout --auto-close --auto-kill --no-cancel --width=300

elif [ "$exit_type" = "Reboot" ]
then
        # Do Reboot here.
        sudo shutdown -r now | zenity --progress --percentage=95 --title=Reboot --auto-close --auto-kill --no-cancel --width=300


elif [ "$exit_type" = "Shutdown" ]
then
        # Do Shutdown here.
    sudo shutdown -h now | zenity --progress --percentage=95 --title=Shutdown --auto-close --auto-kill --no-cancel --width=300

else

#if [ "$exit_type" = "Cancel" ]
#then
        # Do Cancel here.
    sleep 1 | zenity --progress --percentage=95 --title=Cancelling Exit --auto-close --auto-kill --no-cancel --width=300
fi

Last edited by oliver (2011-08-20 20:53:54)

Offline

#2 2011-02-03 15:28:28

pablokal
Administrator
From: Nijmegen, Holland
Registered: 2010-10-12
Posts: 2,625
Website

Re: Zenity shutdown, reboot,logout script.

This does the same using python:
http://crunchbang.org/archives/2008/04/ … wn-script/

Were did you find your script?


Getting your questions answered here at ArchBang Forums
Please! Always give hardware info, if there is a chance that 's relevant: #lspci -vnn
Quote: What I have learnt from Linux is to minimize dependencies and functionalities for greater independence.
On Arch(bang) and Openbox: http://stillstup.blogspot.com/

Offline

#3 2011-02-04 01:08:44

xunil
Member
Registered: 2011-02-03
Posts: 26

Re: Zenity shutdown, reboot,logout script.

pablokal wrote:

This does the same using python:
http://crunchbang.org/archives/2008/04/ … wn-script/

Were did you find your script?

The Zenity script is beter, because you don't need to have hal running or gdm installed.
It makes openbox lighter.

I found it on this blog:

http://bimma.me.uk/2011/01/01/zenity-ex … r-openbox/

Sorry for my bad English!

Last edited by xunil (2011-02-05 05:09:07)

Offline

#4 2011-02-04 08:20:55

pablokal
Administrator
From: Nijmegen, Holland
Registered: 2010-10-12
Posts: 2,625
Website

Re: Zenity shutdown, reboot,logout script.

Thanks, xunil.
The link is important to get the correct code in the zip file.

And don't worry about your English; as long as we understand each other everything is ok.


Getting your questions answered here at ArchBang Forums
Please! Always give hardware info, if there is a chance that 's relevant: #lspci -vnn
Quote: What I have learnt from Linux is to minimize dependencies and functionalities for greater independence.
On Arch(bang) and Openbox: http://stillstup.blogspot.com/

Offline

#5 2011-08-20 00:42:24

krax
New member
Registered: 2011-08-20
Posts: 2

Re: Zenity shutdown, reboot,logout script.

Thanks for your nice conterbution
here 2 questions comes to mind:
1. how could we do this script with Consolekit instead of messing with sudoers file?
(how could we put dbus command in zenity)

2. what is the suspend command. you didn't paste it!!!

Offline

#6 2011-08-20 16:58:50

pablokal
Administrator
From: Nijmegen, Holland
Registered: 2010-10-12
Posts: 2,625
Website

Re: Zenity shutdown, reboot,logout script.

zenity is just a notification program.
Consolekit is a possibility, I suppose, but you can screw that up too.
You will need to use vim or nano to edit the sudoers file.
See here how to use nano: http://stillstup.blogspot.com/2010/11/g … on-in.html
If you are afraid of making errors make a backup or copy it.


Getting your questions answered here at ArchBang Forums
Please! Always give hardware info, if there is a chance that 's relevant: #lspci -vnn
Quote: What I have learnt from Linux is to minimize dependencies and functionalities for greater independence.
On Arch(bang) and Openbox: http://stillstup.blogspot.com/

Offline

Board footer

Powered by FluxBB