slitaz-tools diff tinyutils/tazx @ rev 856
Edit tinyutils
author | Paul Issott <paul@slitaz.org> |
---|---|
date | Fri Apr 18 20:01:11 2014 +0100 (2014-04-18) |
parents | 66de501eccc6 |
children | 0746b6a94061 |
line diff
1.1 --- a/tinyutils/tazx Tue Mar 18 19:31:26 2014 +0000 1.2 +++ b/tinyutils/tazx Fri Apr 18 20:01:11 2014 +0100 1.3 @@ -10,18 +10,21 @@ 1.4 # 1.5 1.6 # 20140317: most xsession, xinitrc are obsolete, provided system files 1.7 -# are in /etc/skel and WM config files are no longer copied by tazx 1.8 -# to user home. If some configs are needed by WMs they should be set 1.9 -# by a /usr/bin/wmname-session script. 1.10 +# are in /etc/skel and WM config files should no longer be copied by 1.11 +# tazx to user home. If some configs are needed by WMs they should 1.12 +# be set by a /usr/bin/wmname-session script I guess. - Pankso 1.13 1.14 . /lib/libtaz.sh 1.15 . /etc/slitaz/slitaz.conf 1.16 +. /etc/slitaz/applications.conf 1.17 + 1.18 +installed="$PKGS_DB/installed" 1.19 + 1.20 export TEXTDOMAIN='slitaz-tools' #i18n 1.21 - 1.22 : ${DIALOG=dialog} 1.23 1.24 # Default value. 1.25 -WM=lxde-session 1.26 +WM=${WINDOW_MANAGER} 1.27 1.28 # Default user for config files in Live mode, id is 1000 since it is 1.29 # created by /etc/init.d/bootopts.sh. 1.30 @@ -144,10 +147,9 @@ 1.31 case $value in 1.32 quit) exit 0 ;; 1.33 *) 1.34 - installed=/var/lib/tazpkg/installed/ 1.35 - [ -d "$installed/xorg-server" ] || tazpkg get-install xorg-server 1.36 + [ -d "$installed/xorg-server" ] || tazpkg -gi xorg-server 1.37 [ -d "$installed/xorg-xf86-video-$value" ] || \ 1.38 - tazpkg get-install xorg-xf86-video-$value 1.39 + tazpkg -gi xorg-xf86-video-$value 1.40 xorg_conf_d ;; 1.41 esac 1.42 } 1.43 @@ -158,13 +160,11 @@ 1.44 exec 3>&1 1.45 value=$($DIALOG \ 1.46 --clear --colors \ 1.47 - --title " $(_n 'Configure X') " \ 1.48 - --menu "\ 1.49 -$(_n 'Tazx dialog helps you to configure your Xorg server.')\n\n\ 1.50 -$(_n 'Window Manager:') \Z2$WM\Zn \n\ 1.51 -$(_n 'X server:') \Z2Xorg\Zn" 16 70 3 \ 1.52 - "xorg" "$(_n 'Install or reconfigure Xorg')" \ 1.53 - "quit" "$(_n 'Quit Tazx utility')" \ 1.54 + --title "{ $(_n 'SliTaz Xorg config') }" \ 1.55 + --menu "" 16 72 10 \ 1.56 + "xorg" "$(_n 'Install or reconfigure Xorg')" \ 1.57 + "xorg-light" "$(_n 'Install Xorg server (light version)')" \ 1.58 + "quit" "$(_n 'Quit Tazx utility')" \ 1.59 2>&1 1>&3) 1.60 retval=$? 1.61 exec 3>&- 1.62 @@ -176,141 +176,50 @@ 1.63 esac 1.64 1.65 # Set selected value. 1.66 - case $value in 1.67 - xorg) 1.68 + case "$value" in 1.69 + xorg) 1.70 install_xorg ;; 1.71 - *) exit 0 ;; 1.72 + xorg-light) 1.73 + [ -d "$installed/xorg-server-light" ] || \ 1.74 + tazpkg -gi xorg-server-light 1.75 + [ -d "$installed/xorg-xf86-video-fbdev" ] || \ 1.76 + tazpkg -gi xorg-xf86-video-fbdev 1.77 + xorg_conf_d ;; 1.78 + *) 1.79 + exit 0 ;; 1.80 esac 1.81 } 1.82 1.83 -# Window manager specific configuration. 1.84 -wm_config() { 1.85 - case $WM in 1.86 - ob|openbox) 1.87 - WM=openbox-session 1.88 - # Check if a personal autostart script exists if OB is installed. 1.89 - if [ -d "$INSTALLED/openbox" ]; then 1.90 - if [ ! -f "$HOME/.config/openbox/autostart.sh" ]; then 1.91 - mkdir -p $HOME/.config/openbox 1.92 - cp /etc/xdg/openbox/autostart.sh $HOME/.config/openbox 1.93 - fi 1.94 - # Script for default user (uid=1000). 1.95 - if [ ! -f "/home/$USER/.config/openbox/autostart.sh" ]; then 1.96 - mkdir -p /home/$USER/.config/openbox 1.97 - cp /etc/xdg/openbox/autostart.sh /home/$USER/.config/openbox 1.98 - fi 1.99 - if [ ! -f "/home/$USER/.config/openbox/menu.xml" ]; then 1.100 - mkdir -p /home/$USER/.config/openbox 1.101 - cp /etc/xdg/openbox/menu.xml /home/$USER/.config/openbox 1.102 - fi 1.103 - chown -R $USER.users /home/$USER/.config 1.104 - fi ;; 1.105 - jwm) 1.106 - WM=jwm 1.107 - JWM_CONFIG=$HOME/.jwmrc 1.108 - if [ -d "$INSTALLED/jwm" ]; then 1.109 - if [ ! -f "$JWM_CONFIG" ]; then 1.110 - cp /etc/jwm/system.jwmrc $JWM_CONFIG 1.111 - fi 1.112 - # In Live mode default user/root JWM config does not exist and 1.113 - # $HOME is not set, this is because tazx is executed by boot 1.114 - # scripts. 1.115 - if [ ! -f "/home/$USER/.jwmrc" ]; then 1.116 - cp /etc/jwm/system.jwmrc /home/$USER/.jwmrc 1.117 - chown $USER.users /home/$USER/.jwmrc 1.118 - fi 1.119 - if [ ! -f "/root/.jwmrc" -a $(id -u) = 0 ]; then 1.120 - cp /etc/jwm/system.jwmrc /root/.jwmrc 1.121 - fi 1.122 - fi ;; 1.123 - pekwm) 1.124 - WM=pekwm 1.125 - if [ -d "$INSTALLED/pekwm" ]; then 1.126 - if [ -d "$HOME/.pekwm" ]; then 1.127 - cp -R /etc/pekwm $HOME/.pekwm 1.128 - fi 1.129 - # In Live mode we want config before starting pekwm the first time. 1.130 - if [ ! -d "/home/$USER/.pekwm" ]; then 1.131 - cp -R /etc/pekwm /home/$USER/.pekwm 1.132 - chown -R $USER.users /home/$USER/.pekwm 1.133 - chmod +x /home/$USER/.pekwm/start 1.134 - fi 1.135 - if [ ! -d "/root/.pekwm" -a `id -u` = 0 ]; then 1.136 - cp -R /etc/pekwm /root/.pekwm 1.137 - chmod +x /root/.pekwm/start 1.138 - fi 1.139 - fi ;; 1.140 - e17|enlightenment) 1.141 - WM=enlightenment_start ;; 1.142 - fluxbox) 1.143 - WM=startfluxbox ;; 1.144 - dwm|karmen) 1.145 - WM=$WM-session ;; 1.146 - awesome) 1.147 - WM=awesome ;; 1.148 - xfce|xfce4) 1.149 - WM=xfce4-session ;; 1.150 - esac 1.151 -} 1.152 - 1.153 -# Sample xinitrc for user (WM can be specified with F1 at slim login). 1.154 -xinitrc_sample() { 1.155 - cat > $1 << "EOF" 1.156 -# ~/.xinitrc: Executed by slim login manager to startx X session. 1.157 -# You can use F1 with Slim to change your window manager or configure 1.158 -# it permanently with your personal applications.conf file. 1.159 -# 1.160 -. $HOME/.config/slitaz/applications.conf 1.161 - 1.162 -case $1 in 1.163 - e17|enlightenment*) exec enlightenment_start ;; 1.164 - openbox|openbox-session|ob) exec openbox-session ;; 1.165 - dwm|dwm-session) exec dwm-session ;; 1.166 - fluxbox|startfluxbox) exec startfluxbox ;; 1.167 - awesome) exec awesome ;; 1.168 - pekwm) exec pekwm ;; 1.169 - karmen|karmen-session) exec karmen-session ;; 1.170 - jwm) lxpanel & exec jwm ;; 1.171 - xfce|xfce4|xfce4-session) xfce4-session ;; 1.172 - *) exec $WINDOW_MANAGER ;; 1.173 -esac 1.174 -EOF 1.175 - # Set default WM in applications.conf user file. Default WM can be 1.176 - # configured graphically with 'desktopbox tazapps' 1.177 - . $CONFIG 1.178 - sed -i 's|WINDOW_MANAGER=.*|WINDOW_MANAGER="'$WM'"|' $CONFIG 1.179 -} 1.180 - 1.181 # ~/.xinitrc for X login from a DM. 1.182 creat_xinitrc() { 1.183 - local APCONF=/etc/slitaz/applications.conf 1.184 - 1.185 - CONFIG=$HOME/.config/slitaz/applications.conf 1.186 - if [ ! -f $CONFIG ]; then 1.187 - mkdir -p $(dirname $CONFIG); cp $APCONF $CONFIG 1.188 + apps_conf=/etc/slitaz/applications.conf 1.189 + user_conf="$HOME/.config/slitaz/applications.conf" 1.190 + xinitrc="$HOME/.xinitrc" 1.191 + if [ ! -f "$user_conf" ]; then 1.192 + mkdir -p $(dirname $user_conf); cp ${apps_conf} ${user_conf} 1.193 fi 1.194 - xinitrc_sample $HOME/.xinitrc 1.195 + if [ ! -f "$xinitrc" ]; then 1.196 + cp /etc/skel/.xinitrc ${xinitrc} 1.197 + fi 1.198 1.199 # Make .xinitrc and config for /etc/skel so new added user will get 1.200 # a working X session. 1.201 if test $(id -u) = 0; then 1.202 - CONFIG=/etc/skel/.config/slitaz/applications.conf 1.203 - mkdir -p $(dirname $CONFIG); cp -f $APCONF $CONFIG 1.204 - xinitrc_sample /etc/skel/.xinitrc 1.205 + user_conf="/etc/skel/.config/slitaz/applications.conf" 1.206 + mkdir -p $(dirname $user_conf); cp -f ${apps_conf} ${user_conf} 1.207 fi 1.208 1.209 - # In Live mode default user needs a xinitrc, since tazx 1.210 - # is executed only by root. 1.211 - CONFIG=/home/$USER/.config/slitaz/applications.conf 1.212 - if [ ! -f $CONFIG ]; then 1.213 - mkdir -p $(dirname $CONFIG); cp $APCONF $CONFIG 1.214 + # In Live mode default user needs a xinitrc, since tazx is executed 1.215 + # only by root. 1.216 + user_conf="/home/$USER/.config/slitaz/applications.conf" 1.217 + xinitrc="/home/$USER/.xinitrc" 1.218 + if [ ! -f "$user_conf" ]; then 1.219 + mkdir -p $(dirname $user_conf); cp ${apps_conf} ${user_conf} 1.220 + chown -R $USER.users $(dirname $user_conf) 1.221 fi 1.222 - chown -R $USER.users /home/$USER/.config/slitaz 1.223 - 1.224 - FILE=/home/$USER/.xinitrc 1.225 - if [ ! -f $FILE ]; then 1.226 - xinitrc_sample $FILE 1.227 - chown $USER.users $FILE 1.228 + if [ ! -f "$xinitrc" ]; then 1.229 + cp -f /etc/skel/.xinitrc ${xinitrc} 1.230 + chown $USER.users ${xinitrc} 1.231 fi 1.232 } 1.233 1.234 @@ -318,60 +227,44 @@ 1.235 # only by startx, Slim login manager uses .xinitrc). 1.236 creat_xsession() { 1.237 local xsession=$HOME/.xsession 1.238 - [ -f $xsession ] && cp -f $xsession $HOME/.previous_xsession 1.239 - cat > $xsession << _EOF_ 1.240 -# ~/.xsession: Start X window session manually on your system (startx). 1.241 + [ -f "$xsession" ] && cp -f ${xsession} ${xsession}.bak 1.242 + cat > ${xsession} << EOT 1.243 +# ~/.xsession: Start X session manually on your system with: startx 1.244 # 1.245 Xorg & 1.246 #xterm & 1.247 -_EOF_ 1.248 - # LXpanel by default with JWM. 1.249 - if [ "$WM" = "jwm" ]; then 1.250 - echo 'lxpanel &' >> $xsession 1.251 - fi 1.252 - echo "exec $WM" >> $xsession 1.253 - chmod 700 $xsession 1.254 +exec $WM 1.255 +EOT 1.256 + chmod 700 ${xsession} 1.257 } 1.258 1.259 - 1.260 -# Commands - WM can be specified on cmdline. 1.261 +# Commands 1.262 1.263 case "$1" in 1.264 install-xorg) 1.265 - check_root $@ 1.266 - if [ -n "$2" ]; then 1.267 - WM=$2 1.268 - fi 1.269 - echo "xorg" > /etc/X11/screen.conf 1.270 + check_root 1.271 install_xorg 1.272 - wm_config 1.273 creat_xinitrc 1.274 creat_xsession ;; 1.275 + 1.276 config-xorg) 1.277 - check_root $@ 1.278 - if [ -n "$2" ]; then 1.279 - WM=$2 1.280 - fi 1.281 - echo "xorg" > /etc/X11/screen.conf 1.282 - wm_config 1.283 + check_root 1.284 creat_xinitrc 1.285 creat_xsession 1.286 - xorg_conf_d 1.287 + xorg_conf_d 1.288 + # Handle live option: screen= 1.289 if grep -qs screen= /proc/cmdline ; then 1.290 MODE="$(sed 's/.*screen=\([0-9]*x[0-9]*\).*/\1/' < /proc/cmdline)" 1.291 sed -i "s/.*EndSubSection.*/\\t\\tModes\\t\"$MODE\"\\n&/" \ 1.292 /etc/X11/xorg.conf.d/70-Screen.conf 1.293 fi ;; 1.294 + 1.295 + *help) 1.296 + echo "Usage: $(basename $0) [install-xorg|config-xorg|]" ;; 1.297 + 1.298 *) 1.299 # User can get a new .xinitrc with tazx from cmdline. 1.300 - if [ -n "$1" ]; then 1.301 - WM=$1 1.302 - fi 1.303 - if test $(id -u) = 0; then 1.304 - echo "xorg" > /etc/X11/screen.conf 1.305 - config_dialog 1.306 - fi 1.307 - wm_config 1.308 + [ $(id -u) == 0 ] && config_dialog 1.309 creat_xinitrc 1.310 creat_xsession ;; 1.311 esac