~raof/gnome-session/fix-bug-623700

« back to all changes in this revision

Viewing changes to debian/gnome-wm

  • Committer: chrisccoulson at googlemail
  • Date: 2009-03-03 20:30:59 UTC
  • Revision ID: chrisccoulson@googlemail.com-20090303203059-hyfc1qt1wccyqsf3
Initial gnome-session import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
 
 
3
# The user can specify his prefered WM by setting the WINDOW_MANAGER
 
4
# environment variable or setting the
 
5
# /desktop/gnome/applications/window_manager/default gconf key.
 
6
#
 
7
# This script has been heavily modified to support Debian's
 
8
# alternatives system.
 
9
 
 
10
# sm-client-id value
 
11
SMID=
 
12
# default-wm value
 
13
DEFWM=
 
14
 
 
15
#read in the arguments
 
16
GET=
 
17
for n in "$@" ; do
 
18
  case "$GET" in
 
19
    smid)
 
20
      SMID=$n
 
21
      GET=
 
22
      ;;
 
23
    defwm)
 
24
      DEFWM=$n
 
25
      GET=
 
26
      ;;
 
27
    *)
 
28
      case "$n" in
 
29
        --sm-client-id)
 
30
          GET=smid
 
31
          ;;
 
32
        --default-wm)
 
33
          GET=defwm
 
34
          ;;
 
35
      esac
 
36
      ;;
 
37
  esac
 
38
done
 
39
 
 
40
# Get previously set window manager in gconf
 
41
if [ ! "$DEFWM" ]; then
 
42
  DEFWM=`gconftool-2 -g /desktop/gnome/applications/window_manager/default 2>/dev/null`
 
43
fi
 
44
 
 
45
if ! which "$WINDOW_MANAGER" > /dev/null; then
 
46
  # Get --default-wm
 
47
  if which "$DEFWM" > /dev/null; then
 
48
    WINDOW_MANAGER=$DEFWM
 
49
    if [ "$WINDOW_MANAGER" = x-window-manager ]; then
 
50
      WINDOW_MANAGER=`readlink /etc/alternatives/x-window-manager 2>/dev/null`
 
51
    fi
 
52
  # if nothing is found, first use metacity
 
53
  elif [ -x /usr/bin/metacity ]; then
 
54
    WINDOW_MANAGER=/usr/bin/metacity
 
55
  elif [ -x /usr/bin/compiz ]; then
 
56
    WINDOW_MANAGER=/usr/bin/compiz
 
57
  elif [ -x /usr/bin/sawfish ]; then
 
58
    WINDOW_MANAGER=/usr/bin/sawfish
 
59
  else
 
60
    WINDOW_MANAGER=`readlink /etc/alternatives/x-window-manager 2>/dev/null`
 
61
  fi
 
62
fi
 
63
 
 
64
# If no window manager can be found, we default to xterm
 
65
if [ ! "$WINDOW_MANAGER" ]; then
 
66
  echo "WARNING: No window manager can be found."
 
67
  WINDOW_MANAGER=`readlink /etc/alternatives/x-terminal-emulator 2>/dev/null`
 
68
fi
 
69
 
 
70
# If there is no xterm, they're really screwed.
 
71
if [ ! "$WINDOW_MANAGER" ]; then
 
72
  echo "ERROR: No window manager and no xterm!"
 
73
  exit 1
 
74
fi
 
75
 
 
76
# Now create options OPT1 and OPT2 based on the windowmanager used
 
77
OPT1=
 
78
OPT2=
 
79
if [ ! -z "$SMID" ] ; then
 
80
  case `basename "$WINDOW_MANAGER"` in
 
81
    sawfish)
 
82
      OPT1=--sm-client-id=$SMID
 
83
      CURRENT=Sawfish
 
84
      ;;
 
85
    compiz)
 
86
      OPT1=--sm-client-id
 
87
      OPT2=$SMID
 
88
      CURRENT=compiz
 
89
      ;;
 
90
    metacity)
 
91
      OPT1=--sm-client-id=$SMID
 
92
      CURRENT=metacity
 
93
      ;;
 
94
    enlightenment|twm)
 
95
      OPT1=-clientId
 
96
      OPT2=$SMID
 
97
      CURRENT=Enlightenment
 
98
      ;;
 
99
    fvwm|fvwm2)
 
100
      OPT1=--clientid
 
101
      OPT2=$SMID
 
102
      CURRENT=fvwm
 
103
      ;;
 
104
    openbox)
 
105
      OPT1=--sm-client-id
 
106
      OPT2=$SMID
 
107
      CURRENT=openbox
 
108
      ;;
 
109
  esac
 
110
fi
 
111
 
 
112
# Store the selected WM with gconf
 
113
gconftool-2 -t string -s /desktop/gnome/applications/window_manager/current "$WINDOW_MANAGER"
 
114
 
 
115
exec "$WINDOW_MANAGER" $OPT1 $OPT2
 
116
 
 
117
echo "ERROR: No window manager could run!"
 
118
exit 1