slitaz-tools view tinyutils/tazx @ rev 203

tazx: source /etc/keymap.conf (kmap.conf is removed)
author Christophe Lincoln <pankso@slitaz.org>
date Tue May 20 17:35:21 2008 +0200 (2008-05-20)
parents 92aedc898747
children 6ecc94a22bf5
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=tazdialog}
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=openbox
20 fi
22 ####################
23 # Tazx functions #
24 ####################
26 # Install xorg server
27 install_xorg()
28 {
29 tazpkg recharge
30 exec 3>&1
31 value=`$DIALOG --clear --colors --title " Install Xorg " \
32 --menu \
33 "L'application 'tazx' permet de configurer le driver X." 16 70 5 \
34 $(grep xorg-xf86-video /var/lib/tazpkg/packages.list | cut -d- -f4 | while read x; do echo $x; echo driver; done) \
35 "quit" "Quitter" \
36 2>&1 1>&3`
37 retval=$?
38 exec 3>&-
39 # Continue, exit...
40 case $retval in
41 1)
42 echo "Cancel pressed..."
43 exit 0 ;;
44 255)
45 if test -z "$value"; then
46 echo "ESC pressed..."
47 exit 0
48 fi ;;
49 esac
50 # Set selected value.
51 case $value in
52 quit)
53 echo "Quit..."
54 exit 0 ;;
55 *)
56 tazpkg get-install xorg-server
57 tazpkg get-install xorg-xf86-video-$value
58 Xorg -configure :1
59 mv /root/xorg.conf.new /etc/X11/xorg.conf
60 . /etc/keymap.conf
61 patch -p0 <<EOF
62 --- /etc/X11/xorg.conf
63 +++ /etc/X11/xorg.conf
64 @@ -30,2 +30,3 @@
65 Driver "kbd"
66 + Option "XkbLayout" "${KMAP%.kmap}"
67 EndSection
68 EOF
69 sed -i 's|/usr/bin/Xvesa|/usr/bin/Xorg|' /etc/slim.conf
70 sed -i s/"^xserver_arguments"/'\#xserver_arguments'/ /etc/slim.conf
71 XSERVER=Xorg;;
72 esac
73 }
75 # Screen configuration dialog.
76 screen_config_dialog()
77 {
78 exec 3>&1
79 value=`$DIALOG --help-button \
80 --clear --colors \
81 --title " Configure X " \
82 --menu \
83 "L'application 'tazx' permet de configurer une session X.\n\
84 Gestionnaire de fenêtres : \Z2$WM\Zn" 16 70 5 \
85 $(Xvesa -listmodes 2>&1 | grep ^0x | awk '{ printf "%s %s\n",$2,$3 }' | sort -nr | grep x[1-2][4-6]) \
86 "xterm" "800x600x16" \
87 "xorg" "Installer Xorg" \
88 "quit" "Quitter" \
89 2>&1 1>&3`
90 retval=$?
91 exec 3>&-
92 # Continue, exit or help...
93 case $retval in
94 0)
95 continue ;;
96 1)
97 echo "Cancel pressed..."
98 exit 0 ;;
99 2)
100 $DIALOG --clear \
101 --title " Aide - Help " --textbox "$DOC" 16 70
102 exec tazx ;;
103 255)
104 if test -n "$value"; then
105 continue
106 else
107 echo "ESC pressed..."
108 exit 0
109 fi ;;
110 esac
111 # Set selected value.
112 case $value in
113 xorg)
114 install_xorg;;
115 xterm)
116 Xvesa -ac -shadow -screen 800x600x16 -br &
117 exec xterm -cr orange -geometry 80x35+0-0 ;;
118 *)
119 NEW_SCREEN=$value ;;
120 esac
121 }
123 # Slim config if root.
124 slim_config()
125 {
126 if test $(id -u) = 0; then
127 # /etc/X11/screen.conf exist for Live mode, if this file dos not
128 # exist tazx is executed at boot time.
129 mkdir -p /etc/X11
130 echo "SCREEN=$NEW_SCREEN" > /etc/X11/screen.conf
131 # Get current screen size and sed config file with the new value.
132 if [ -f /etc/slim.conf ]; then
133 RES=$(grep ^xserver_arguments /etc/slim.conf | sed 's/xserver_arguments.*-screen *//')
134 sed -i "s/\(xserver_arguments.*-screen\).*/\1 $NEW_SCREEN/" /etc/slim.conf
135 fi
136 JWM_CONFIG=/etc/jwm/system.jwmrc
137 fi
138 }
140 # e17 start with enlightenment_start.
141 e17_stuff()
142 {
143 if [ "$WM" == "e17" ]; then
144 WM=enlightenment_start
145 XSEVER_OPTS="dpms -terminate"
146 fi
147 }
149 # Openbox with openbox-session.
150 openbox_stuff()
151 {
152 if [ "$WM" == "openbox" -o "$WM" == "ob" ]; then
153 WM=openbox-session
154 XSEVER_OPTS="dpms +extension Composite"
155 fi
156 # Check if a personnal autostart script exist if OB is installed.
157 if [ -d "/var/lib/tazpkg/installed/openbox" ]; then
158 if [ ! -f "$HOME/.config/openbox/autostart.sh" ]; then
159 mkdir -p $HOME/.config/openbox
160 cp /etc/xdg/openbox/autostart.sh $HOME/.config/openbox
161 fi
162 # Script for hacker.
163 if [ ! -f "/home/hacker/.config/openbox/autostart.sh" ]; then
164 mkdir -p /home/hacker/.config/openbox
165 cp /etc/xdg/openbox/autostart.sh /home/hacker/.config/openbox
166 fi
167 if [ ! -f "/home/hacker/.config/openbox/menu.xml" ]; then
168 mkdir -p /home/hacker/.config/openbox
169 cp /etc/xdg/openbox/menu.xml /home/hacker/.config/openbox
170 fi
171 chown -R hacker.hacker /home/hacker/.config
172 fi
173 }
175 # Sample xinitrc for user (WM can be specified with F1 at slim login).
176 xinitrc_sample()
177 {
178 cat > $FILE << "EOF"
179 # ~/.xinitrc: Executed by slim login manager to startx X session.
180 # You can use F1 with Slim or 'tazx' to configure permanantly
181 # your default WM: tazx e17
182 #
183 WM=openbox-session
185 case $1 in
186 e17|enlightenment_start)
187 exec enlightenment_start
188 ;;
189 openbox|openbox-session|ob)
190 exec openbox-session
191 ;;
192 jwm)
193 lxpanel &
194 exec jwm
195 ;;
196 *)
197 exec $WM
198 ;;
199 esac
200 EOF
201 # Set default WM.
202 RES=`grep ^WM=[e-o] $FILE`
203 sed -i s/"$RES"/"WM=$WM"/ $FILE
204 }
206 # ~/.xinitrc for slim login.
207 creat_xinitrc()
208 {
209 FILE=$HOME/.xinitrc
210 xinitrc_sample
212 # In Live mode hacker needs a xinitrc, since tazx
213 # is executed only by root.
214 if [ ! -f /home/hacker/.xinitrc ]; then
215 FILE=/home/hacker/.xinitrc
216 xinitrc_sample
217 chown hacker.hacker $FILE
218 fi
219 }
221 # Copy a JWM system config if any present in user home.
222 jwm_config()
223 {
224 if [ -d "/var/lib/tazpkg/installed/jwm" ]; then
225 JWM_CONFIG=$HOME/.jwmrc
226 if [ ! -f "$JWM_CONFIG" ]; then
227 cp /etc/jwm/system.jwmrc $JWM_CONFIG
228 fi
229 # In Live mode hacker/root JWM config dose not exist ans $HOME is
230 # ot set, this is because tazx is executed by boot scripts.
231 if [ ! -f "/home/hacker/.jwmrc" ]; then
232 JWM_CONFIG=/home/hacker/.jwmrc
233 cp /etc/jwm/system.jwmrc $JWM_CONFIG
234 chown hacker.hacker $JWM_CONFIG
235 fi
236 if [ ! -f "/root/.jwmrc" -a `id -u` = 0 ]; then
237 JWM_CONFIG=/root/.jwmrc
238 cp /etc/jwm/system.jwmrc $JWM_CONFIG
239 fi
240 fi
241 }
243 # Creat ~/.xsession to keep the configuration selected (used
244 # only by startx, Slim login manager use .xinitrc).
245 creat_xsession()
246 {
247 cat > $HOME/.xsession << _EOF_
248 # ~/.xsession: Start X window session manually on your system (startx).
249 #
250 _EOF_
251 if [ "$XSERVER " == "Xorg" ]; then
252 echo 'Xorg &' >> $HOME/.xsession
253 else
254 echo "$XSERVER -ac -shadow $XSEVER_OPTS -screen $NEW_SCREEN -mouse $MOUSE &" \
255 >> $HOME/.xsession
256 fi
257 echo '#xterm &' >> $HOME/.xsession
258 echo '#xpad &' >> $HOME/.xsession
259 # LXpanel by default with JWM.
260 if [ "$WM" = "jwm" ]; then
261 echo 'lxpanel &' >> $HOME/.xsession
262 fi
263 echo "exec $WM" >> $HOME/.xsession
264 chmod 700 $HOME/.xsession
265 }
267 ###################
268 # Tazx sequence #
269 ###################
271 [ -n "$NEW_SCREEN" ] || screen_config_dialog
272 slim_config
273 e17_stuff
274 openbox_stuff
275 creat_xinitrc
276 jwm_config
277 creat_xsession
279 exit 0