[openbox] Conservative exit?
Michael Heerdegen
michael_heerdegen at web.de
Tue Jan 15 17:24:11 EST 2013
Hi Anthony,
> You could always download and use a very old application....
>
> XCloseDown
>
> It first sends 'delete window' to all X window appliactions to ask them
> politly to close their windows and exit. Then afetr a moment sends a
> 'kill client' signal to force the X window program to kill off the client
> connections.
thanks for your answer! Interesting, I didn't know XCloseDown.
But most of the time, it's not what I want. I normally close all
applications by hand after I finished using them and before logout, and
only if I forgot one, I want to get a warning message instead of the
logout when trying to exit openbox, so that I can take care of what I
had forgotten. Especially, I don't want anything to be killed
automatically.
I massaged the script I had found under
http://daemon-notes.com/articles/desktop/openbox/configs a bit to get
this work. If any running X app is found (except for panels etc.), the
script just exits with a message. Here is the result, for those who are
interested:
--8<---------------cut here---------------start------------->8---
#!/usr/bin/env bash
# derived from a script found at
# from http://daemon-notes.com/articles/desktop/openbox/configs
EXIT_COMMAND="openbox --exit"
ACTION=$1
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/root/bin
NUM_DISPLAYS=`xvinfo | grep 'screen #' | wc -l`
CUR_DISPLAY=0
while [ $CUR_DISPLAY -lt $NUM_DISPLAYS ]; do
export DISPLAY=":0.$CUR_DISPLAY"
CLIENTS=""
WINDOWS=`xprop -root _NET_CLIENT_LIST | awk -F# '{ print $2; }' | tr -d ","`
for ID in $WINDOWS; do
WINDOW_TYPE=`xprop -id $ID _NET_WM_WINDOW_TYPE`
TYPE_NOT_SET=`echo $WINDOW_TYPE | grep "not found" | wc -l`
TYPE_NORMAL=`echo $WINDOW_TYPE | grep _NET_WM_WINDOW_TYPE_NORMAL | wc -l`
if [ $TYPE_NOT_SET -eq 1 -o $TYPE_NORMAL -eq 1 ]; then
CLIENTS="$CLIENTS $ID"
fi
done
if [ -n "$CLIENTS" ]; then
xmessage -center "Please close all clients first"
exit;
fi
CUR_DISPLAY=`expr $CUR_DISPLAY + 1`
done
export DISPLAY=":0.0"
case $ACTION in
-r)
sudo reboot
;;
-h)
sudo halt -p
;;
*)
$EXIT_COMMAND
;;
esac
--8<---------------cut here---------------end--------------->8---
Regards,
Michael.
More information about the openbox
mailing list