rev |
line source |
pankso@4
|
1 #!/bin/sh
|
pankso@4
|
2 #
|
pankso@66
|
3 # Tazx - Ncurses X configuration for SliTaz GNU/Linux using Dialog boxes.
|
pankso@4
|
4 # This tinyutils is part of slitaz-tools.
|
pankso@4
|
5 #
|
pankso@209
|
6 # (c) 20080609 SliTaz GNU/Linux - GNU gpl v3.
|
pankso@209
|
7 # Authors: Christophe Lincoln <pankso@slitaz.org>
|
pankso@209
|
8 # Pascal Bellard <pascal.bellard@slitaz.org>
|
pankso@4
|
9 #
|
pascal@190
|
10 : ${DIALOG=tazdialog}
|
pankso@4
|
11
|
pankso@4
|
12 # Variables.
|
pankso@66
|
13 #
|
pankso@4
|
14 XSERVER=Xvesa
|
pankso@4
|
15 DOC=/usr/share/doc/slitaz-tools/tazx.txt
|
pankso@4
|
16 MOUSE=/dev/input/mice,5
|
pankso@46
|
17 # WM can be specified on cmdline.
|
pankso@46
|
18 if [ -n "$1" ]; then
|
pankso@46
|
19 WM=$1
|
pankso@46
|
20 else
|
pankso@158
|
21 WM=openbox
|
pankso@46
|
22 fi
|
pankso@209
|
23 # Default user for config files
|
pankso@209
|
24 USER=`cat /etc/passwd | grep 1000 | cut -d ":" -f 1`
|
pankso@4
|
25
|
pankso@66
|
26 ####################
|
pankso@66
|
27 # Tazx functions #
|
pankso@66
|
28 ####################
|
pankso@66
|
29
|
pankso@260
|
30 # Patch xorg.conf to set keymap layout.
|
pankso@260
|
31 patch_xorg_kbd()
|
pankso@260
|
32 {
|
pankso@260
|
33 KEYMAP=`cat /etc/keymap.conf`
|
pankso@260
|
34 case $KEYMAP in
|
pankso@260
|
35 fr_CH-latin1)
|
pankso@260
|
36 # Swiss FrenCH
|
pankso@260
|
37 patch -p0 <<EOF
|
pankso@260
|
38 --- /etc/X11/xorg.conf
|
pankso@260
|
39 +++ /etc/X11/xorg.conf
|
pankso@260
|
40 @@ -30,2 +30,3 @@
|
pankso@260
|
41 Driver "kbd"
|
pankso@260
|
42 + Option "XkbLayout" "ch"
|
pankso@260
|
43 + Option "XkbVariant" "fr"
|
pankso@260
|
44 EndSection
|
pankso@260
|
45 EOF
|
pankso@260
|
46 ;;
|
pankso@260
|
47 en)
|
pankso@260
|
48 # Englisk UK
|
pankso@260
|
49 patch -p0 <<EOF
|
pankso@260
|
50 --- /etc/X11/xorg.conf
|
pankso@260
|
51 +++ /etc/X11/xorg.conf
|
pankso@260
|
52 @@ -30,2 +30,3 @@
|
pankso@260
|
53 Driver "kbd"
|
pankso@260
|
54 + Option "XkbLayout" "en"
|
pankso@260
|
55 + Option "XkbVariant" "en"
|
pankso@260
|
56 EndSection
|
pankso@260
|
57 EOF
|
pankso@260
|
58 ;;
|
pankso@260
|
59 ru)
|
pankso@260
|
60 # Russian
|
pankso@260
|
61 patch -p0 <<EOF
|
pankso@260
|
62 --- /etc/X11/xorg.conf
|
pankso@260
|
63 +++ /etc/X11/xorg.conf
|
pankso@260
|
64 @@ -30,2 +30,3 @@
|
pankso@260
|
65 Driver "kbd"
|
pankso@260
|
66 + Option "XkbLayout" "us,ru(winkeys)"
|
pankso@260
|
67 + Option "XkbVariant" "grp:alt_shift_toggle"
|
pankso@260
|
68 EndSection
|
pankso@260
|
69 EOF
|
pankso@260
|
70 ;;
|
pankso@303
|
71 slovene)
|
pankso@303
|
72 # Slovenian
|
pankso@303
|
73 patch -p0 <<EOF
|
pankso@303
|
74 --- /etc/X11/xorg.conf
|
pankso@303
|
75 +++ /etc/X11/xorg.conf
|
pankso@303
|
76 @@ -30,2 +30,3 @@
|
pankso@303
|
77 Driver "kbd"
|
pankso@303
|
78 + Option "XkbLayout" "si"
|
pankso@303
|
79 + Option "XkbOptions" "grp:alt_shift_toggle"
|
pankso@303
|
80 EndSection
|
pankso@303
|
81 EOF
|
pankso@308
|
82 ;;
|
pankso@260
|
83 *)
|
pankso@260
|
84 # Use clean /etc/keymap.conf value.
|
pankso@260
|
85 KEYMAP=${KEYMAP%-latin1}
|
pankso@260
|
86 KEYMAP=${KEYMAP%-lat2}
|
pankso@260
|
87 KEYMAP=${KEYMAP%-lat6}
|
pankso@260
|
88 KEYMAP=${KEYMAP%-abnt2}
|
pankso@260
|
89 patch -p0 <<EOF
|
pankso@260
|
90 --- /etc/X11/xorg.conf
|
pankso@260
|
91 +++ /etc/X11/xorg.conf
|
pankso@260
|
92 @@ -30,2 +30,3 @@
|
pankso@260
|
93 Driver "kbd"
|
pankso@260
|
94 + Option "XkbLayout" "$KEYMAP"
|
pankso@260
|
95 EndSection
|
pankso@260
|
96 EOF
|
pankso@260
|
97 ;;
|
pankso@260
|
98 esac
|
pankso@260
|
99 }
|
pankso@260
|
100
|
pankso@117
|
101 # Install xorg server
|
pankso@117
|
102 install_xorg()
|
pankso@117
|
103 {
|
pankso@117
|
104 tazpkg recharge
|
pankso@117
|
105 exec 3>&1
|
pankso@117
|
106 value=`$DIALOG --clear --colors --title " Install Xorg " \
|
pankso@117
|
107 --menu \
|
pankso@117
|
108 "L'application 'tazx' permet de configurer le driver X." 16 70 5 \
|
pankso@117
|
109 $(grep xorg-xf86-video /var/lib/tazpkg/packages.list | cut -d- -f4 | while read x; do echo $x; echo driver; done) \
|
pankso@117
|
110 "quit" "Quitter" \
|
pankso@117
|
111 2>&1 1>&3`
|
pankso@117
|
112 retval=$?
|
pankso@117
|
113 exec 3>&-
|
pankso@117
|
114 # Continue, exit...
|
pankso@117
|
115 case $retval in
|
pankso@117
|
116 1)
|
pankso@117
|
117 echo "Cancel pressed..."
|
pankso@117
|
118 exit 0 ;;
|
pankso@117
|
119 255)
|
pankso@117
|
120 if test -z "$value"; then
|
pankso@117
|
121 echo "ESC pressed..."
|
pankso@117
|
122 exit 0
|
pankso@117
|
123 fi ;;
|
pankso@117
|
124 esac
|
pankso@117
|
125 # Set selected value.
|
pankso@117
|
126 case $value in
|
pankso@117
|
127 quit)
|
pankso@117
|
128 echo "Quit..."
|
pankso@117
|
129 exit 0 ;;
|
pankso@117
|
130 *)
|
pankso@117
|
131 tazpkg get-install xorg-server
|
pankso@117
|
132 tazpkg get-install xorg-xf86-video-$value
|
pascal@124
|
133 Xorg -configure :1
|
pankso@117
|
134 mv /root/xorg.conf.new /etc/X11/xorg.conf
|
pankso@260
|
135 patch_xorg_kbd
|
pankso@117
|
136 sed -i 's|/usr/bin/Xvesa|/usr/bin/Xorg|' /etc/slim.conf
|
pankso@117
|
137 sed -i s/"^xserver_arguments"/'\#xserver_arguments'/ /etc/slim.conf
|
pankso@117
|
138 XSERVER=Xorg;;
|
pankso@117
|
139 esac
|
pankso@117
|
140 }
|
pankso@117
|
141
|
pankso@66
|
142 # Screen configuration dialog.
|
pankso@66
|
143 screen_config_dialog()
|
pankso@66
|
144 {
|
pankso@66
|
145 exec 3>&1
|
pankso@66
|
146 value=`$DIALOG --help-button \
|
pankso@66
|
147 --clear --colors \
|
pankso@66
|
148 --title " Configure X " \
|
pankso@66
|
149 --menu \
|
pankso@66
|
150 "L'application 'tazx' permet de configurer une session X.\n\
|
pankso@66
|
151 Gestionnaire de fenêtres : \Z2$WM\Zn" 16 70 5 \
|
pankso@118
|
152 $(Xvesa -listmodes 2>&1 | grep ^0x | awk '{ printf "%s %s\n",$2,$3 }' | sort -nr | grep x[1-2][4-6]) \
|
pankso@66
|
153 "xterm" "800x600x16" \
|
pankso@117
|
154 "xorg" "Installer Xorg" \
|
pankso@66
|
155 "quit" "Quitter" \
|
pankso@66
|
156 2>&1 1>&3`
|
pankso@66
|
157 retval=$?
|
pankso@66
|
158 exec 3>&-
|
pankso@66
|
159 # Continue, exit or help...
|
pankso@66
|
160 case $retval in
|
pankso@66
|
161 0)
|
pankso@66
|
162 continue ;;
|
pankso@66
|
163 1)
|
pankso@66
|
164 echo "Cancel pressed..."
|
pankso@66
|
165 exit 0 ;;
|
pankso@66
|
166 2)
|
pankso@66
|
167 $DIALOG --clear \
|
pankso@66
|
168 --title " Aide - Help " --textbox "$DOC" 16 70
|
pankso@66
|
169 exec tazx ;;
|
pankso@66
|
170 255)
|
pankso@66
|
171 if test -n "$value"; then
|
pankso@66
|
172 continue
|
pankso@66
|
173 else
|
pankso@66
|
174 echo "ESC pressed..."
|
pankso@66
|
175 exit 0
|
pankso@66
|
176 fi ;;
|
pankso@66
|
177 esac
|
pankso@66
|
178 # Set selected value.
|
pankso@66
|
179 case $value in
|
pankso@117
|
180 xorg)
|
pankso@117
|
181 install_xorg;;
|
pankso@66
|
182 xterm)
|
pankso@66
|
183 Xvesa -ac -shadow -screen 800x600x16 -br &
|
pankso@66
|
184 exec xterm -cr orange -geometry 80x35+0-0 ;;
|
pankso@66
|
185 *)
|
pankso@68
|
186 NEW_SCREEN=$value ;;
|
pankso@66
|
187 esac
|
pankso@66
|
188 }
|
pankso@4
|
189
|
pankso@65
|
190 # Slim config if root.
|
pankso@66
|
191 slim_config()
|
pankso@66
|
192 {
|
pankso@66
|
193 if test $(id -u) = 0; then
|
pankso@68
|
194 # /etc/X11/screen.conf exist for Live mode, if this file dos not
|
pankso@68
|
195 # exist tazx is executed at boot time.
|
pankso@68
|
196 mkdir -p /etc/X11
|
pankso@68
|
197 echo "SCREEN=$NEW_SCREEN" > /etc/X11/screen.conf
|
pankso@67
|
198 # Get current screen size and sed config file with the new value.
|
pankso@66
|
199 if [ -f /etc/slim.conf ]; then
|
pankso@67
|
200 RES=$(grep ^xserver_arguments /etc/slim.conf | sed 's/xserver_arguments.*-screen *//')
|
pankso@69
|
201 sed -i "s/\(xserver_arguments.*-screen\).*/\1 $NEW_SCREEN/" /etc/slim.conf
|
pankso@66
|
202 fi
|
pankso@66
|
203 JWM_CONFIG=/etc/jwm/system.jwmrc
|
pankso@65
|
204 fi
|
pankso@66
|
205 }
|
pankso@66
|
206
|
pankso@66
|
207 # e17 start with enlightenment_start.
|
pankso@66
|
208 e17_stuff()
|
pankso@66
|
209 {
|
pankso@66
|
210 if [ "$WM" == "e17" ]; then
|
pankso@66
|
211 WM=enlightenment_start
|
pankso@66
|
212 XSEVER_OPTS="dpms -terminate"
|
pankso@65
|
213 fi
|
pankso@66
|
214 }
|
pankso@65
|
215
|
pankso@81
|
216 # Openbox with openbox-session.
|
pankso@81
|
217 openbox_stuff()
|
pankso@81
|
218 {
|
pankso@81
|
219 if [ "$WM" == "openbox" -o "$WM" == "ob" ]; then
|
pankso@81
|
220 WM=openbox-session
|
pankso@158
|
221 XSEVER_OPTS="dpms +extension Composite"
|
pankso@81
|
222 fi
|
MikeDSmith25@252
|
223 # Check if a personal autostart script exists if OB is installed.
|
pankso@81
|
224 if [ -d "/var/lib/tazpkg/installed/openbox" ]; then
|
pankso@81
|
225 if [ ! -f "$HOME/.config/openbox/autostart.sh" ]; then
|
pankso@81
|
226 mkdir -p $HOME/.config/openbox
|
pankso@81
|
227 cp /etc/xdg/openbox/autostart.sh $HOME/.config/openbox
|
pankso@81
|
228 fi
|
pankso@209
|
229 # Script for default user (uid=1000).
|
pankso@209
|
230 if [ ! -f "/home/$USER/.config/openbox/autostart.sh" ]; then
|
pankso@209
|
231 mkdir -p /home/$USER/.config/openbox
|
pankso@209
|
232 cp /etc/xdg/openbox/autostart.sh /home/$USER/.config/openbox
|
pankso@81
|
233 fi
|
pankso@209
|
234 if [ ! -f "/home/$USER/.config/openbox/menu.xml" ]; then
|
pankso@209
|
235 mkdir -p /home/$USER/.config/openbox
|
pankso@209
|
236 cp /etc/xdg/openbox/menu.xml /home/$USER/.config/openbox
|
pankso@158
|
237 fi
|
pankso@209
|
238 chown -R $USER.$USER /home/$USER/.config
|
pankso@81
|
239 fi
|
pankso@81
|
240 }
|
pankso@81
|
241
|
pankso@68
|
242 # Sample xinitrc for user (WM can be specified with F1 at slim login).
|
pankso@68
|
243 xinitrc_sample()
|
pankso@68
|
244 {
|
pankso@68
|
245 cat > $FILE << "EOF"
|
pankso@68
|
246 # ~/.xinitrc: Executed by slim login manager to startx X session.
|
pankso@203
|
247 # You can use F1 with Slim or 'tazx' to configure permanantly
|
pankso@99
|
248 # your default WM: tazx e17
|
pankso@68
|
249 #
|
pankso@162
|
250 WM=openbox-session
|
pankso@99
|
251
|
pankso@117
|
252 case $1 in
|
pankso@68
|
253 e17|enlightenment_start)
|
pankso@68
|
254 exec enlightenment_start
|
pankso@68
|
255 ;;
|
pankso@162
|
256 openbox|openbox-session|ob)
|
pankso@81
|
257 exec openbox-session
|
pankso@81
|
258 ;;
|
pankso@117
|
259 jwm)
|
pankso@81
|
260 lxpanel &
|
pankso@68
|
261 exec jwm
|
pankso@68
|
262 ;;
|
pankso@117
|
263 *)
|
pankso@117
|
264 exec $WM
|
pankso@117
|
265 ;;
|
pankso@68
|
266 esac
|
pankso@68
|
267 EOF
|
pankso@122
|
268 # Set default WM.
|
pankso@122
|
269 RES=`grep ^WM=[e-o] $FILE`
|
pankso@122
|
270 sed -i s/"$RES"/"WM=$WM"/ $FILE
|
pankso@68
|
271 }
|
pankso@68
|
272
|
pankso@65
|
273 # ~/.xinitrc for slim login.
|
pankso@66
|
274 creat_xinitrc()
|
pankso@66
|
275 {
|
pankso@68
|
276 FILE=$HOME/.xinitrc
|
pankso@68
|
277 xinitrc_sample
|
pankso@203
|
278
|
pankso@209
|
279 # In Live mode default user needs a xinitrc, since tazx
|
pankso@68
|
280 # is executed only by root.
|
pankso@209
|
281 if [ ! -f /home/$USER/.xinitrc ]; then
|
pankso@209
|
282 FILE=/home/$USER/.xinitrc
|
pankso@68
|
283 xinitrc_sample
|
pankso@209
|
284 chown $USER.$USER $FILE
|
pankso@66
|
285 fi
|
pankso@66
|
286 }
|
pankso@65
|
287
|
pankso@66
|
288 # Copy a JWM system config if any present in user home.
|
pankso@66
|
289 jwm_config()
|
pankso@66
|
290 {
|
pankso@162
|
291 if [ -d "/var/lib/tazpkg/installed/jwm" ]; then
|
pankso@162
|
292 JWM_CONFIG=$HOME/.jwmrc
|
pankso@162
|
293 if [ ! -f "$JWM_CONFIG" ]; then
|
pankso@162
|
294 cp /etc/jwm/system.jwmrc $JWM_CONFIG
|
pankso@162
|
295 fi
|
pankso@209
|
296 # In Live mode default user/root JWM config dose not exist and
|
pankso@209
|
297 # $HOME is ot set, this is because tazx is executed by boot
|
pankso@209
|
298 # scripts.
|
pankso@209
|
299 if [ ! -f "/home/$USER/.jwmrc" ]; then
|
pankso@209
|
300 JWM_CONFIG=/home/$USER/.jwmrc
|
pankso@162
|
301 cp /etc/jwm/system.jwmrc $JWM_CONFIG
|
pankso@209
|
302 chown $USER.$USER $JWM_CONFIG
|
pankso@162
|
303 fi
|
pankso@162
|
304 if [ ! -f "/root/.jwmrc" -a `id -u` = 0 ]; then
|
pankso@162
|
305 JWM_CONFIG=/root/.jwmrc
|
pankso@162
|
306 cp /etc/jwm/system.jwmrc $JWM_CONFIG
|
pankso@162
|
307 fi
|
pankso@105
|
308 fi
|
pankso@66
|
309 }
|
pankso@45
|
310
|
MikeDSmith25@252
|
311 # Create ~/.xsession to keep the configuration selected (used
|
MikeDSmith25@252
|
312 # only by startx, Slim login manager uses .xinitrc).
|
pankso@66
|
313 creat_xsession()
|
pankso@66
|
314 {
|
pankso@68
|
315 cat > $HOME/.xsession << _EOF_
|
pankso@68
|
316 # ~/.xsession: Start X window session manually on your system (startx).
|
pankso@37
|
317 #
|
pankso@68
|
318 _EOF_
|
pankso@117
|
319 if [ "$XSERVER " == "Xorg" ]; then
|
pankso@117
|
320 echo 'Xorg &' >> $HOME/.xsession
|
pankso@117
|
321 else
|
pankso@117
|
322 echo "$XSERVER -ac -shadow $XSEVER_OPTS -screen $NEW_SCREEN -mouse $MOUSE &" \
|
pankso@117
|
323 >> $HOME/.xsession
|
pankso@117
|
324 fi
|
pankso@117
|
325 echo '#xterm &' >> $HOME/.xsession
|
pankso@117
|
326 echo '#xpad &' >> $HOME/.xsession
|
pankso@99
|
327 # LXpanel by default with JWM.
|
pankso@117
|
328 if [ "$WM" = "jwm" ]; then
|
pankso@99
|
329 echo 'lxpanel &' >> $HOME/.xsession
|
pankso@99
|
330 fi
|
pankso@104
|
331 echo "exec $WM" >> $HOME/.xsession
|
pankso@66
|
332 chmod 700 $HOME/.xsession
|
pankso@66
|
333 }
|
pankso@4
|
334
|
pankso@66
|
335 ###################
|
pankso@66
|
336 # Tazx sequence #
|
pankso@66
|
337 ###################
|
pankso@66
|
338
|
pascal@96
|
339 [ -n "$NEW_SCREEN" ] || screen_config_dialog
|
pankso@66
|
340 slim_config
|
pankso@66
|
341 e17_stuff
|
pankso@81
|
342 openbox_stuff
|
pankso@66
|
343 creat_xinitrc
|
pankso@66
|
344 jwm_config
|
pankso@66
|
345 creat_xsession
|
pankso@4
|
346
|
pankso@4
|
347 exit 0
|