slitaz-tools rev 66
Improved tazx and clean code
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Fri Feb 22 22:57:37 2008 +0100 (2008-02-22) |
parents | 24536a8294f8 |
children | f08ba67c03a6 |
files | tinyutils/tazx |
line diff
1.1 --- a/tinyutils/tazx Fri Feb 22 19:51:43 2008 +0100 1.2 +++ b/tinyutils/tazx Fri Feb 22 22:57:37 2008 +0100 1.3 @@ -1,13 +1,14 @@ 1.4 #!/bin/sh 1.5 # 1.6 -# Tazx - Ncurses startx script for SliTaz GNU/Linux using Dialog boxes. 1.7 +# Tazx - Ncurses X configuration for SliTaz GNU/Linux using Dialog boxes. 1.8 # This tinyutils is part of slitaz-tools. 1.9 # 1.10 -# 20080205 <pankso@slitaz.org> - GNU gpl v3. 1.11 +# 20080222 <pankso@slitaz.org> - GNU gpl v3. 1.12 # 1.13 : ${DIALOG=dialog} 1.14 1.15 # Variables. 1.16 +# 1.17 XSERVER=Xvesa 1.18 DOC=/usr/share/doc/slitaz-tools/tazx.txt 1.19 MOUSE=/dev/input/mice,5 1.20 @@ -18,6 +19,10 @@ 1.21 WM=jwm 1.22 fi 1.23 1.24 +#################### 1.25 +# Tazx functions # 1.26 +#################### 1.27 + 1.28 # Change backgroud image if the 3/4 is not respected. 1.29 change_jwm_background() 1.30 { 1.31 @@ -32,101 +37,128 @@ 1.32 fi 1.33 } 1.34 1.35 -# Main dialog. 1.36 -exec 3>&1 1.37 -value=`$DIALOG --help-button \ 1.38 - --clear --colors \ 1.39 - --title " Configure X " \ 1.40 - --menu \ 1.41 -"L'application 'tazx' permet de configurer votre session X.\n\ 1.42 -Gestionnaire de fenêtres : \Z2$WM\Zn" 16 70 5 \ 1.43 -"640x400x16" "TrueColor" \ 1.44 -"640x400x24" "TrueColor" \ 1.45 -"640x480x16" "TrueColor" \ 1.46 -"640x480x24" "TrueColor" \ 1.47 -"800x600x16" "TrueColor" \ 1.48 -"800x600x24" "TrueColor" \ 1.49 -"1024x768x16" "TrueColor" \ 1.50 -"1024x768x24" "TrueColor" \ 1.51 -"1280x800x16" "TrueColor" \ 1.52 -"1280x800x24" "TrueColor" \ 1.53 -"1280x1024x16" "TrueColor" \ 1.54 -"1280x1024x24" "TrueColor" \ 1.55 -"1600x1200x16" "TrueColor" \ 1.56 -"1600x1200x24" "TrueColor" \ 1.57 -"1920x1440x16" "TrueColor" \ 1.58 -"xterm" "800x600x16" \ 1.59 -"quit" "Quitter" \ 1.60 -2>&1 1>&3` 1.61 -retval=$? 1.62 -exec 3>&- 1.63 - 1.64 -# Continue, exit or help... 1.65 -case $retval in 1.66 - 0) 1.67 - continue ;; 1.68 - 1) 1.69 - echo "Cancel pressed..." 1.70 - exit 0 ;; 1.71 - 2) 1.72 - $DIALOG --clear \ 1.73 - --title " Aide - Help " --textbox "$DOC" 15 70 1.74 - exec tazx ;; 1.75 - 255) 1.76 - if test -n "$value"; then 1.77 - continue 1.78 - else 1.79 - echo "ESC pressed..." 1.80 - exit 0 1.81 - fi ;; 1.82 -esac 1.83 - 1.84 -# Set selected value. 1.85 -case $value in 1.86 - xterm) 1.87 - Xvesa -ac -shadow -screen 800x600x16 -br & 1.88 - exec xterm -cr orange -geometry 80x35+0-0 ;; 1.89 - *) 1.90 - NEW_SCREEN=$value ;; 1.91 -esac 1.92 +# Screen configuration dialog. 1.93 +screen_config_dialog() 1.94 +{ 1.95 + exec 3>&1 1.96 + value=`$DIALOG --help-button \ 1.97 + --clear --colors \ 1.98 + --title " Configure X " \ 1.99 + --menu \ 1.100 + "L'application 'tazx' permet de configurer une session X.\n\ 1.101 + Gestionnaire de fenêtres : \Z2$WM\Zn" 16 70 5 \ 1.102 + "640x400x16" "TrueColor" \ 1.103 + "640x400x24" "TrueColor" \ 1.104 + "640x480x16" "TrueColor" \ 1.105 + "640x480x24" "TrueColor" \ 1.106 + "800x600x16" "TrueColor" \ 1.107 + "800x600x24" "TrueColor" \ 1.108 + "1024x768x16" "TrueColor" \ 1.109 + "1024x768x24" "TrueColor" \ 1.110 + "1280x800x16" "TrueColor" \ 1.111 + "1280x800x24" "TrueColor" \ 1.112 + "1280x1024x16" "TrueColor" \ 1.113 + "1280x1024x24" "TrueColor" \ 1.114 + "1600x1200x16" "TrueColor" \ 1.115 + "1600x1200x24" "TrueColor" \ 1.116 + "1920x1440x16" "TrueColor" \ 1.117 + "xterm" "800x600x16" \ 1.118 + "quit" "Quitter" \ 1.119 + 2>&1 1>&3` 1.120 + retval=$? 1.121 + exec 3>&- 1.122 + # Continue, exit or help... 1.123 + case $retval in 1.124 + 0) 1.125 + continue ;; 1.126 + 1) 1.127 + echo "Cancel pressed..." 1.128 + exit 0 ;; 1.129 + 2) 1.130 + $DIALOG --clear \ 1.131 + --title " Aide - Help " --textbox "$DOC" 16 70 1.132 + exec tazx ;; 1.133 + 255) 1.134 + if test -n "$value"; then 1.135 + continue 1.136 + else 1.137 + echo "ESC pressed..." 1.138 + exit 0 1.139 + fi ;; 1.140 + esac 1.141 + # Set selected value. 1.142 + case $value in 1.143 + xterm) 1.144 + Xvesa -ac -shadow -screen 800x600x16 -br & 1.145 + exec xterm -cr orange -geometry 80x35+0-0 ;; 1.146 + *) 1.147 + NEW_SCREEN=$value ;; 1.148 + esac 1.149 +} 1.150 1.151 # Slim config if root. 1.152 -if test $(id -u) = 0; then 1.153 - # Get current screen size or set default to 1024x768x24 to sed 1.154 - # config file with the new value. 1.155 - if [ -f /etc/X11/screen.conf ]; then 1.156 - . /etc/X11/screen.conf 1.157 - else 1.158 - SCREEN=1024x768x24 1.159 +slim_config() 1.160 +{ 1.161 + if test $(id -u) = 0; then 1.162 + # Get current screen size or set default to 1024x768x24 to sed 1.163 + # config file with the new value. 1.164 + if [ -f /etc/X11/screen.conf ]; then 1.165 + . /etc/X11/screen.conf 1.166 + else 1.167 + SCREEN=1024x768x24 1.168 + fi 1.169 + if [ -f /etc/slim.conf ]; then 1.170 + mkdir -p /etc/X11 1.171 + echo "SCREEN=$NEW_SCREEN" > /etc/X11/screen.conf 1.172 + sed -i s/"$SCREEN"/"$NEW_SCREEN"/ /etc/slim.conf 1.173 + fi 1.174 + JWM_CONFIG=/etc/jwm/system.jwmrc 1.175 + change_jwm_background 1.176 fi 1.177 - if [ -f /etc/slim.conf ]; then 1.178 - mkdir -p /etc/X11 1.179 - echo "SCREEN=$NEW_SCREEN" > /etc/X11/screen.conf 1.180 - sed -i s/"$SCREEN"/"$NEW_SCREEN"/ /etc/slim.conf 1.181 +} 1.182 + 1.183 +# e17 start with enlightenment_start. 1.184 +e17_stuff() 1.185 +{ 1.186 + if [ "$WM" == "e17" ]; then 1.187 + WM=enlightenment_start 1.188 + XSEVER_OPTS="dpms -terminate" 1.189 fi 1.190 - JWM_CONFIG=/etc/jwm/system.jwmrc 1.191 - change_jwm_background 1.192 -fi 1.193 +} 1.194 1.195 # ~/.xinitrc for slim login. 1.196 -echo "$WM" > $HOME/.xinitrc 1.197 +creat_xinitrc() 1.198 +{ 1.199 + echo "$WM" > $HOME/.xinitrc 1.200 + if [ ! -f /home/hacker/.xinitrc ]; then 1.201 + echo "$WM" > /home/hacker/.xinitrc 1.202 + chown hacker.hacker /home/hacker/.xinitrc 1.203 + fi 1.204 +} 1.205 1.206 -# Copy a JWM system config if any present in user home 1.207 -if [ ! -f "$HOME/.jwmrc" ]; then 1.208 - cp /etc/jwm/system.jwmrc $HOME/.jwmrc 1.209 -fi 1.210 -JWM_CONFIG=$HOME/.jwmrc 1.211 -change_jwm_background 1.212 +# Copy a JWM system config if any present in user home. 1.213 +jwm_config() 1.214 +{ 1.215 + if [ ! -f "$HOME/.jwmrc" ]; then 1.216 + cp /etc/jwm/system.jwmrc $HOME/.jwmrc 1.217 + JWM_CONFIG=$HOME/.jwmrc 1.218 + change_jwm_background 1.219 + fi 1.220 + # In Live mode hacker JWM config dose not exist, this is 1.221 + # because tazx is executed at boot time by root. 1.222 + if [ ! -f "/home/hacker/.jwmrc" ]; then 1.223 + cp /etc/jwm/system.jwmrc /home/hacker/.jwmrc 1.224 + JWM_CONFIG=/home/hacker/.jwmrc 1.225 + change_jwm_background 1.226 + chown hacker.hacker $JWM_CONFIG 1.227 + fi 1.228 +} 1.229 1.230 -# e17 start with enlightenment_start. 1.231 -if [ "$WM" == "e17" ]; then 1.232 - WM=enlightenment_start 1.233 - XSEVER_OPTS="dpms -terminate" 1.234 -fi 1.235 - 1.236 -# Creat ~/.xsession to keep the configuration selected. 1.237 -# 1.238 -cat > $HOME/.xsession << _EOT_ 1.239 +# Creat ~/.xsession to keep the configuration selected (used 1.240 +# only by startx, Slim login manager use .xinitrc). 1.241 +creat_xsession() 1.242 +{ 1.243 + cat > $HOME/.xsession << _EOT_ 1.244 # ~/.xsession: Start X window session on your system. 1.245 # 1.246 $XSERVER -ac -shadow $XSEVER_OPTS -screen $NEW_SCREEN -mouse $MOUSE & 1.247 @@ -134,13 +166,29 @@ 1.248 #xpad & 1.249 exec $WM 1.250 _EOT_ 1.251 -chmod 700 $HOME/.xsession 1.252 + chmod 700 $HOME/.xsession 1.253 +} 1.254 1.255 -# Console messages. 1.256 -echo "" 1.257 -echo "X server : $XSERVER" 1.258 -echo "Screen : $NEW_SCREEN" 1.259 -echo "Exec WM : $WM" 1.260 -echo "" 1.261 +# Console message. 1.262 +console_message() 1.263 +{ 1.264 + echo "" 1.265 + echo "X server : $XSERVER" 1.266 + echo "Screen : $NEW_SCREEN" 1.267 + echo "Exec WM : $WM" 1.268 + echo "" 1.269 +} 1.270 + 1.271 +################### 1.272 +# Tazx sequence # 1.273 +################### 1.274 + 1.275 +screen_config_dialog 1.276 +slim_config 1.277 +e17_stuff 1.278 +creat_xinitrc 1.279 +jwm_config 1.280 +creat_xsession 1.281 +console_message 1.282 1.283 exit 0