slitaz-tools view tinyutils/tazx @ rev 105

We dont need multi-wallpapers now (Thank Pascal)
author Christophe Lincoln <pankso@slitaz.org>
date Thu Mar 13 01:33:02 2008 +0100 (2008-03-13)
parents 4eaba614e892
children d30840862d0c
line source
1 #!/bin/sh
2 #
3 # Tazx - Ncurses X configuration for SliTaz GNU/Linux using Dialog boxes.
4 # This tinyutils is part of slitaz-tools.
5 #
6 # 20080313 <pankso@slitaz.org> - GNU gpl v3.
7 #
8 : ${DIALOG=dialog}
10 # Variables.
11 #
12 XSERVER=Xvesa
13 DOC=/usr/share/doc/slitaz-tools/tazx.txt
14 MOUSE=/dev/input/mice,5
15 # WM can be specified on cmdline.
16 if [ -n "$1" ]; then
17 WM=$1
18 else
19 WM=jwm
20 fi
22 ####################
23 # Tazx functions #
24 ####################
26 # Screen configuration dialog.
27 screen_config_dialog()
28 {
29 exec 3>&1
30 value=`$DIALOG --help-button \
31 --clear --colors \
32 --title " Configure X " \
33 --menu \
34 "L'application 'tazx' permet de configurer une session X.\n\
35 Gestionnaire de fenêtres : \Z2$WM\Zn" 16 70 5 \
36 "640x400x16" "TrueColor" \
37 "640x400x24" "TrueColor" \
38 "640x480x16" "TrueColor" \
39 "640x480x24" "TrueColor" \
40 "800x600x16" "TrueColor" \
41 "800x600x24" "TrueColor" \
42 "1024x768x16" "TrueColor" \
43 "1024x768x24" "TrueColor" \
44 "1280x800x16" "TrueColor" \
45 "1280x800x24" "TrueColor" \
46 "1280x1024x16" "TrueColor" \
47 "1280x1024x24" "TrueColor" \
48 "1600x1200x16" "TrueColor" \
49 "1600x1200x24" "TrueColor" \
50 "1920x1440x16" "TrueColor" \
51 "xterm" "800x600x16" \
52 "quit" "Quitter" \
53 2>&1 1>&3`
54 retval=$?
55 exec 3>&-
56 # Continue, exit or help...
57 case $retval in
58 0)
59 continue ;;
60 1)
61 echo "Cancel pressed..."
62 exit 0 ;;
63 2)
64 $DIALOG --clear \
65 --title " Aide - Help " --textbox "$DOC" 16 70
66 exec tazx ;;
67 255)
68 if test -n "$value"; then
69 continue
70 else
71 echo "ESC pressed..."
72 exit 0
73 fi ;;
74 esac
75 # Set selected value.
76 case $value in
77 xterm)
78 Xvesa -ac -shadow -screen 800x600x16 -br &
79 exec xterm -cr orange -geometry 80x35+0-0 ;;
80 *)
81 NEW_SCREEN=$value ;;
82 esac
83 }
85 # Slim config if root.
86 slim_config()
87 {
88 if test $(id -u) = 0; then
89 # /etc/X11/screen.conf exist for Live mode, if this file dos not
90 # exist tazx is executed at boot time.
91 mkdir -p /etc/X11
92 echo "SCREEN=$NEW_SCREEN" > /etc/X11/screen.conf
93 # Get current screen size and sed config file with the new value.
94 if [ -f /etc/slim.conf ]; then
95 RES=$(grep ^xserver_arguments /etc/slim.conf | sed 's/xserver_arguments.*-screen *//')
96 sed -i "s/\(xserver_arguments.*-screen\).*/\1 $NEW_SCREEN/" /etc/slim.conf
97 fi
98 JWM_CONFIG=/etc/jwm/system.jwmrc
99 change_jwm_background
100 fi
101 }
103 # e17 start with enlightenment_start.
104 e17_stuff()
105 {
106 if [ "$WM" == "e17" ]; then
107 WM=enlightenment_start
108 XSEVER_OPTS="dpms -terminate"
109 fi
110 }
112 # Openbox with openbox-session.
113 openbox_stuff()
114 {
115 if [ "$WM" == "openbox" -o "$WM" == "ob" ]; then
116 WM=openbox-session
117 XSEVER_OPTS="dpms -terminate"
118 fi
119 # Check if a personnal autostart script exist if OB is installed.
120 if [ -d "/var/lib/tazpkg/installed/openbox" ]; then
121 if [ ! -f "$HOME/.config/openbox/autostart.sh" ]; then
122 mkdir -p $HOME/.config/openbox
123 cp /etc/xdg/openbox/autostart.sh $HOME/.config/openbox
124 fi
125 # Script for hacker, Openbox can be used with a LiveCD flavor or
126 # LiveUSB.
127 if [ ! -f "/home/hacker/.config/openbox/autostart.sh" ]; then
128 mkdir -p /home/hacker/.config/openbox
129 cp /etc/xdg/openbox/autostart.sh /home/hacker/.config/openbox
130 chown -R hacker.hacker /home/hacker/.config
131 fi
132 fi
133 }
135 # Sample xinitrc for user (WM can be specified with F1 at slim login).
136 xinitrc_sample()
137 {
138 cat > $FILE << "EOF"
139 # ~/.xinitrc: Executed by slim login manager to startx X session.
140 # You can use F1 with Slim or 'tazx' to configure permanantly
141 # your default WM: tazx e17
142 #
143 WM=jwm
145 if [ -n $1 ]; then
146 WM=$1
147 fi
149 case $WM in
150 e17|enlightenment_start)
151 exec enlightenment_start
152 ;;
153 openbox|openbox-session)
154 exec openbox-session
155 ;;
156 jwm|*)
157 lxpanel &
158 exec jwm
159 ;;
160 esac
161 EOF
162 }
164 # ~/.xinitrc for slim login.
165 creat_xinitrc()
166 {
167 FILE=$HOME/.xinitrc
168 xinitrc_sample
171 # In Live mode hacker needs a xinitrc, since tazx
172 # is executed only by root.
173 if [ ! -f /home/hacker/.xinitrc ]; then
174 FILE=/home/hacker/.xinitrc
175 xinitrc_sample
176 chown hacker.hacker $FILE
177 fi
178 # Set default WM.
179 RES=`grep ^WM=[e-o] $HOME/.xinitrc`
180 sed -i s/"$RES"/"WM=$WM"/ $HOME/.xinitrc
181 }
183 # Copy a JWM system config if any present in user home.
184 jwm_config()
185 {
186 JWM_CONFIG=$HOME/.jwmrc
187 if [ ! -f "$JWM_CONFIG" ]; then
188 cp /etc/jwm/system.jwmrc $JWM_CONFIG
189 fi
190 # In Live mode hacker/root JWM config dose not exist ans $HOME is
191 # ot set, this is because tazx is executed by boot scripts.
192 if [ ! -f "/home/hacker/.jwmrc" ]; then
193 JWM_CONFIG=/home/hacker/.jwmrc
194 cp /etc/jwm/system.jwmrc $JWM_CONFIG
195 chown hacker.hacker $JWM_CONFIG
196 fi
197 if [ ! -f "/root/.jwmrc" ]; then
198 JWM_CONFIG=/root/.jwmrc
199 cp /etc/jwm/system.jwmrc $JWM_CONFIG
200 fi
201 }
203 # Creat ~/.xsession to keep the configuration selected (used
204 # only by startx, Slim login manager use .xinitrc).
205 creat_xsession()
206 {
207 cat > $HOME/.xsession << _EOF_
208 # ~/.xsession: Start X window session manually on your system (startx).
209 #
210 $XSERVER -ac -shadow $XSEVER_OPTS -screen $NEW_SCREEN -mouse $MOUSE &
211 #xterm &
212 #xpad &
213 _EOF_
214 # LXpanel by default with JWM.
215 if [ "$WM" = "jwm" ];then
216 echo 'lxpanel &' >> $HOME/.xsession
217 fi
218 echo "exec $WM" >> $HOME/.xsession
219 chmod 700 $HOME/.xsession
220 }
222 ###################
223 # Tazx sequence #
224 ###################
226 [ -n "$NEW_SCREEN" ] || screen_config_dialog
227 slim_config
228 e17_stuff
229 openbox_stuff
230 creat_xinitrc
231 jwm_config
232 creat_xsession
234 exit 0