slitaz-tools view tinyutils/tazx @ rev 116

typos in rootcd/README (2)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Mar 20 11:10:47 2008 +0000 (2008-03-20)
parents d30840862d0c
children acd9704ca411
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 $(Xvesa -listmodes 2>&1 | grep ^0x | awk '{ printf "%s %s\n",$2,$3 }' | sort -nr) \
37 "xterm" "800x600x16" \
38 "quit" "Quitter" \
39 2>&1 1>&3`
40 retval=$?
41 exec 3>&-
42 # Continue, exit or help...
43 case $retval in
44 0)
45 continue ;;
46 1)
47 echo "Cancel pressed..."
48 exit 0 ;;
49 2)
50 $DIALOG --clear \
51 --title " Aide - Help " --textbox "$DOC" 16 70
52 exec tazx ;;
53 255)
54 if test -n "$value"; then
55 continue
56 else
57 echo "ESC pressed..."
58 exit 0
59 fi ;;
60 esac
61 # Set selected value.
62 case $value in
63 xterm)
64 Xvesa -ac -shadow -screen 800x600x16 -br &
65 exec xterm -cr orange -geometry 80x35+0-0 ;;
66 *)
67 NEW_SCREEN=$value ;;
68 esac
69 }
71 # Slim config if root.
72 slim_config()
73 {
74 if test $(id -u) = 0; then
75 # /etc/X11/screen.conf exist for Live mode, if this file dos not
76 # exist tazx is executed at boot time.
77 mkdir -p /etc/X11
78 echo "SCREEN=$NEW_SCREEN" > /etc/X11/screen.conf
79 # Get current screen size and sed config file with the new value.
80 if [ -f /etc/slim.conf ]; then
81 RES=$(grep ^xserver_arguments /etc/slim.conf | sed 's/xserver_arguments.*-screen *//')
82 sed -i "s/\(xserver_arguments.*-screen\).*/\1 $NEW_SCREEN/" /etc/slim.conf
83 fi
84 JWM_CONFIG=/etc/jwm/system.jwmrc
85 fi
86 }
88 # e17 start with enlightenment_start.
89 e17_stuff()
90 {
91 if [ "$WM" == "e17" ]; then
92 WM=enlightenment_start
93 XSEVER_OPTS="dpms -terminate"
94 fi
95 }
97 # Openbox with openbox-session.
98 openbox_stuff()
99 {
100 if [ "$WM" == "openbox" -o "$WM" == "ob" ]; then
101 WM=openbox-session
102 XSEVER_OPTS="dpms -terminate"
103 fi
104 # Check if a personnal autostart script exist if OB is installed.
105 if [ -d "/var/lib/tazpkg/installed/openbox" ]; then
106 if [ ! -f "$HOME/.config/openbox/autostart.sh" ]; then
107 mkdir -p $HOME/.config/openbox
108 cp /etc/xdg/openbox/autostart.sh $HOME/.config/openbox
109 fi
110 # Script for hacker, Openbox can be used with a LiveCD flavor or
111 # LiveUSB.
112 if [ ! -f "/home/hacker/.config/openbox/autostart.sh" ]; then
113 mkdir -p /home/hacker/.config/openbox
114 cp /etc/xdg/openbox/autostart.sh /home/hacker/.config/openbox
115 chown -R hacker.hacker /home/hacker/.config
116 fi
117 fi
118 }
120 # Sample xinitrc for user (WM can be specified with F1 at slim login).
121 xinitrc_sample()
122 {
123 cat > $FILE << "EOF"
124 # ~/.xinitrc: Executed by slim login manager to startx X session.
125 # You can use F1 with Slim or 'tazx' to configure permanantly
126 # your default WM: tazx e17
127 #
128 WM=jwm
130 if [ -n $1 ]; then
131 WM=$1
132 fi
134 case $WM in
135 e17|enlightenment_start)
136 exec enlightenment_start
137 ;;
138 openbox|openbox-session)
139 exec openbox-session
140 ;;
141 jwm|*)
142 lxpanel &
143 exec jwm
144 ;;
145 esac
146 EOF
147 }
149 # ~/.xinitrc for slim login.
150 creat_xinitrc()
151 {
152 FILE=$HOME/.xinitrc
153 xinitrc_sample
156 # In Live mode hacker needs a xinitrc, since tazx
157 # is executed only by root.
158 if [ ! -f /home/hacker/.xinitrc ]; then
159 FILE=/home/hacker/.xinitrc
160 xinitrc_sample
161 chown hacker.hacker $FILE
162 fi
163 # Set default WM.
164 RES=`grep ^WM=[e-o] $HOME/.xinitrc`
165 sed -i s/"$RES"/"WM=$WM"/ $HOME/.xinitrc
166 }
168 # Copy a JWM system config if any present in user home.
169 jwm_config()
170 {
171 JWM_CONFIG=$HOME/.jwmrc
172 if [ ! -f "$JWM_CONFIG" ]; then
173 cp /etc/jwm/system.jwmrc $JWM_CONFIG
174 fi
175 # In Live mode hacker/root JWM config dose not exist ans $HOME is
176 # ot set, this is because tazx is executed by boot scripts.
177 if [ ! -f "/home/hacker/.jwmrc" ]; then
178 JWM_CONFIG=/home/hacker/.jwmrc
179 cp /etc/jwm/system.jwmrc $JWM_CONFIG
180 chown hacker.hacker $JWM_CONFIG
181 fi
182 if [ ! -f "/root/.jwmrc" ]; then
183 JWM_CONFIG=/root/.jwmrc
184 cp /etc/jwm/system.jwmrc $JWM_CONFIG
185 fi
186 }
188 # Creat ~/.xsession to keep the configuration selected (used
189 # only by startx, Slim login manager use .xinitrc).
190 creat_xsession()
191 {
192 cat > $HOME/.xsession << _EOF_
193 # ~/.xsession: Start X window session manually on your system (startx).
194 #
195 $XSERVER -ac -shadow $XSEVER_OPTS -screen $NEW_SCREEN -mouse $MOUSE &
196 #xterm &
197 #xpad &
198 _EOF_
199 # LXpanel by default with JWM.
200 if [ "$WM" = "jwm" ];then
201 echo 'lxpanel &' >> $HOME/.xsession
202 fi
203 echo "exec $WM" >> $HOME/.xsession
204 chmod 700 $HOME/.xsession
205 }
207 ###################
208 # Tazx sequence #
209 ###################
211 [ -n "$NEW_SCREEN" ] || screen_config_dialog
212 slim_config
213 e17_stuff
214 openbox_stuff
215 creat_xinitrc
216 jwm_config
217 creat_xsession
219 exit 0