Fix bug #4492 better, the test in openbox-gnome-session needs to be inverted
[dana/openbox.git] / data / xsession / openbox-gnome-session.in
1 #!/bin/sh
2
3 if test -n "$1"; then
4     echo "Syntax: openbox-gnome-session"
5     echo
6     echo "See the openbox-gnome-session(1) manpage for help."
7   exit
8 fi
9
10 # Clean up after GDM
11 xprop -root -remove _NET_NUMBER_OF_DESKTOPS \
12       -remove _NET_DESKTOP_NAMES \
13       -remove _NET_CURRENT_DESKTOP 2> /dev/null
14
15 VER=$(gnome-session --version 2>/dev/null | \
16       sed -e 's/[^0-9.]*\([0-9.]\+\)/\1/')
17
18 MAJOR=$(echo $VER | cut -d . -f 1)
19 MINOR=$(echo $VER | cut -d . -f 2)
20
21 # run GNOME with Openbox as its window manager
22
23 if test $MAJOR -lt 2 || (test $MAJOR = 2 && test $MINOR -le 22); then
24   # old gnome-session was easy to work with
25   export WINDOW_MANAGER="@bindir@/openbox"
26   exec gnome-session --choose-session=openbox-session "$@"
27 else
28   # new gnome-session requires openbox to be set in gconf and an
29   # openbox.desktop to be installed in the applications directory
30
31   SPATH=/desktop/gnome/session
32
33   # get the current default session
34   SESSION=$(gconftool-2 -g $SPATH/default_session 2> /dev/null)
35
36   # make sure openbox is going to be run
37   if test -z "$SESSION"; then
38       # if its empty then just run openbox
39       SESSION="[openbox]"
40   elif ! echo "$SESSION" | grep -q openbox; then
41       # if openbox isn't in the session then append it
42       SESSION="${SESSION%]},openbox]"
43   fi
44
45   # get the current GNOME/Openbox session
46   OB_SESSION=$(gconftool-2 -g $SPATH/openbox_session 2> /dev/null)
47
48   # update the GNOME/Openbox session if needed
49   if test x$OB_SESSION != x$SESSION; then
50       # the default session changed or we didn't run GNOME/Openbox before
51       gconftool-2 -t list --list-type=strings -s $SPATH/openbox_session \
52         "$SESSION" 2> /dev/null
53   fi
54
55   # run GNOME/Openbox
56   exec gnome-session --default-session-key $SPATH/openbox_session "$@"
57 fi
58
59
60