[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Tk-Skript for shutting down the box [Was: Re: rebooting as user]



Mullins, Ron hat gesagt: // Mullins, Ron wrote:

> C-A-Rubout drops me to a console, yes. Using xdm/wdm/gdm that console isn't
> logged in. This then leaves me with, "Ok, honey...now that you've killed the
> window manager, you now have to login again, then you can hit C-A-Del. (me
> gets blank stare, then "Why?")"
> 
> Hmmm...this is turning out to be more than I thought.

I use a little script at all my home machines, that requires no
gnome, no [kd]wm just tcl/tk an plain xdm. I found this on this
list some years ago, but I don't know the author anymore.

The trick is: The Xserver is running as root anyway, so if you can get
the xserver to run the shutdown command, there is no need to mess with
sudo etc.

Anyway here is the script (slighly modified and translated to german by
me ;)

Installation is simple. Put the attached tkmgr-skript in /usr/local/bin

You have to edit two config files. First put the following at the end of 
"/etc/X11/xdm/Xsetup_0" 

# ---- snip Xsetup_0 --
# Starting the shutdownmanager:
/usr/local/bin/tkmgr &
echo $! > /var/run/tkmgr-pid
# ---- snip -----------

Then put this in "/etc/X11/xdm/Xstartup_0":

# ---- snip Xstartup_0 --
# :0 specific startup commands go here

# Kill the Shutdownmanager:
if [ -f /var/run/tkmgr-pid ]
then
  kill `cat /var/run/tkmgr-pid`
  rm -f /var/run/tkmgr-pid
fi
# ---- snip  --
    

That's it. 

bye
-- 
                                                 __    __
 Frank Barknecht       ____ ______   ____ __ trip\ \  / /wire ______
                      / __// __  /__/ __// // __  \ \/ /  __ \\  ___\	
                     / /  / ____/  / /  / // ____// /\ \\  ___\\____ \	
                    /_/  /_____/  /_/  /_//_____// /  \ \\_____\\_____\
                                                /_/    \_\ 
#!/usr/bin/wishx

# Init stuff
wm title . Chooser
wm protocol . WM_DELETE_WINDOW Quit

# Ganz unten
wm geometry . +1-1

# The buttons
frame .buttons
button .buttons.reboot \
        -text "System neu starten" \
        -width 19 \
        -command Reboot
button .buttons.halt \
        -text "System runterfahren" \
        -width 19 \
        -command Halt
pack append .buttons \
        .buttons.halt   {left expand fill} \
        .buttons.reboot {left expand fill}

pack .buttons -side top -fill x -expand true

# The Functions
proc Quit {} {
    exit 0
}

proc Reboot {} {
    exec /sbin/shutdown -rt 15 now < /dev/tty1 > /dev/tty1 2> /dev/tty1 &
}

proc Halt {} {
    exec /sbin/shutdown -ht 15 now < /dev/tty1 > /dev/tty1 2> /dev/tty1 &
}


Reply to: