slitaz-tools rev 535

tazx: clean kdrive code and create user configs in /etc/skel
author Christophe Lincoln <pankso@slitaz.org>
date Tue Jan 04 01:02:26 2011 +0100 (2011-01-04)
parents a5216abd91c5
children 466b25aa321a
files tinyutils/tazx
line diff
     1.1 --- a/tinyutils/tazx	Tue Jan 04 00:44:00 2011 +0100
     1.2 +++ b/tinyutils/tazx	Tue Jan 04 01:02:26 2011 +0100
     1.3 @@ -1,19 +1,16 @@
     1.4  #!/bin/sh
     1.5  #
     1.6  # Tazx - Ncurses X configuration for SliTaz GNU/Linux using Dialog boxes.
     1.7 -# This tinyutils is part of slitaz-tools. Tazx can configure Xvesa kdrive
     1.8 -# and Xorg with several Window Managers.
     1.9 +# This tinyutils is part of slitaz-tools. Tazx can configure Xorg with 
    1.10 +# several Window Managers.
    1.11  #
    1.12 -# (c) 2010 SliTaz GNU/Linux - GNU gpl v3.
    1.13 +# (c) 2011 SliTaz GNU/Linux - GNU gpl v3.
    1.14  # Authors: Christophe Lincoln <pankso@slitaz.org>
    1.15  #          Pascal Bellard <pascal.bellard@slitaz.org>
    1.16  #
    1.17  : ${DIALOG=tazdialog}
    1.18  
    1.19 -# Default value fo Xvesa.
    1.20 -XSERVER=Xvesa
    1.21 -KEYBD=keyboard
    1.22 -MOUSE=mouse,5,/dev/input/mice
    1.23 +# Default value.
    1.24  WM=openbox
    1.25  
    1.26  # Default user for config files in Live mode, id is 1000 since it is
    1.27 @@ -138,33 +135,17 @@
    1.28  screen_config_dialog()
    1.29  {
    1.30  	exec 3>&1
    1.31 -	if [ -x /usr/bin/Xvesa ]; then
    1.32 -		value=`$DIALOG \
    1.33 -			--clear --colors \
    1.34 -			--title " Configure X " \
    1.35 -			--menu \
    1.36 -		"The 'tazx' application helps you to configure your X session.\n\
    1.37 -		Window Manager : \Z2$WM\Zn \n\
    1.38 -		X server : \Z2Xvesa\Zn" 16 70 5 \
    1.39 -		$(Xvesa -listmodes 2>&1 | grep ^0x | awk '{ printf "%s %s\n",$2,$3 }' | sort -nr | grep x[1-2][4-6]) \
    1.40 -		"xterm" "800x600x16" \
    1.41 -		"xorg" "Install or reconfigure Xorg" \
    1.42 -		"text" "Disable X autostart" \
    1.43 -		"quit" "Quit Tazx utility" \
    1.44 -		2>&1 1>&3`
    1.45 -	else
    1.46 -		value=`$DIALOG \
    1.47 -			--clear --colors \
    1.48 -			--title " Configure X " \
    1.49 -			--menu \
    1.50 -		"The 'tazx' application helps you to configure your X session.\n\
    1.51 -		Window Manager : \Z2$WM\Zn \n\
    1.52 -		X server : \Z2Xorg\Zn" 16 70 5 \
    1.53 -		"xorg" "Install or reconfigure Xorg" \
    1.54 -		"text" "Disable X autostart" \
    1.55 -		"quit" "Quit Tazx utility" \
    1.56 -		2>&1 1>&3`
    1.57 -	fi
    1.58 +	value=`$DIALOG \
    1.59 +		--clear --colors \
    1.60 +		--title " Configure X " \
    1.61 +		--menu \
    1.62 +	"The 'tazx' application helps you to configure your X session.\n\
    1.63 +	Window Manager : \Z2$WM\Zn \n\
    1.64 +	X server : \Z2Xorg\Zn" 16 70 5 \
    1.65 +	"xorg" "Install or reconfigure Xorg" \
    1.66 +	"text" "Disable X autostart" \
    1.67 +	"quit" "Quit Tazx utility" \
    1.68 +	2>&1 1>&3`
    1.69  	retval=$?
    1.70  	exec 3>&-
    1.71  	# Continue, exit or help...
    1.72 @@ -186,45 +167,20 @@
    1.73  	case $value in
    1.74  		xorg)
    1.75  			install_xorg ;;
    1.76 -		xterm)
    1.77 -			# Only with Xvesa.
    1.78 -			Xvesa -ac -shadow -screen 800x600x16 -br &
    1.79 -			exec xterm -cr orange -geometry 80x35+0-0 ;;
    1.80  		text)
    1.81  			sed -i s/'slim'/''/ /etc/rcS.conf
    1.82  			exit 0 ;;
    1.83  		*)
    1.84 -			NEW_SCREEN=$value ;;
    1.85 +			continue ;;
    1.86  	esac
    1.87  }
    1.88  
    1.89 -# Slim config if root.
    1.90 -slim_config()
    1.91 -{
    1.92 -	if test $(id -u) = 0; then
    1.93 -		# /etc/X11/screen.conf exists for Live mode, if this file does not
    1.94 -		# exist tazx is executed at boot time.
    1.95 -		mkdir -p /etc/X11
    1.96 -		echo "SCREEN=$NEW_SCREEN" > /etc/X11/screen.conf
    1.97 -		# Get current screen size and sed config file with the new value.
    1.98 -		if [ -f /etc/slim.conf ]; then
    1.99 -			    XSERV_ARGS=$(grep ^xserver_arguments /etc/slim.conf)
   1.100 -				RES=$( echo $XSERV_ARGS | sed 's/xserver_arguments.*-screen *//' | awk '{print $1 }') 
   1.101 -				NEW_XSERV_ARGS=$(echo $XSERV_ARGS | sed  s/"-screen $RES"/"-screen $NEW_SCREEN"/) 
   1.102 -			# Comment the old one and put the new one in the config file
   1.103 -			sed -i 's/"$XSERV_ARGS"/"# $XSERV_ARGS\n$NEW_XSERV_ARGS"/' /etc/slim.conf 
   1.104 -
   1.105 -		fi
   1.106 -	fi
   1.107 -}
   1.108 -
   1.109  # Window manager specific configuration.
   1.110  wm_config()
   1.111  {
   1.112  	case $WM in
   1.113  		ob|openbox)
   1.114  			WM=openbox-session
   1.115 -			XSEVER_OPTS="dpms +extension Composite"
   1.116  			# Check if a personal autostart script exists if OB is installed.
   1.117  			if [ -d "/var/lib/tazpkg/installed/openbox" ]; then
   1.118  				if [ ! -f "$HOME/.config/openbox/autostart.sh" ]; then
   1.119 @@ -244,7 +200,6 @@
   1.120  			fi ;;
   1.121  		jwm)
   1.122  			WM=jwm
   1.123 -			XSEVER_OPTS="dpms +extension Composite"
   1.124  			JWM_CONFIG=$HOME/.jwmrc
   1.125  			if [ -d "/var/lib/tazpkg/installed/jwm" ]; then
   1.126  				if [ ! -f "$JWM_CONFIG" ]; then
   1.127 @@ -263,7 +218,6 @@
   1.128  			fi ;;
   1.129  		pekwm)
   1.130  			WM=pekwm
   1.131 -			XSEVER_OPTS="dpms"
   1.132  			if [ -d "/var/lib/tazpkg/installed/pekwm" ]; then
   1.133  				if [ -d "$HOME/.pekwm" ]; then
   1.134  					cp -R /etc/pekwm $HOME/.pekwm
   1.135 @@ -280,20 +234,15 @@
   1.136  				fi
   1.137  			fi ;;
   1.138  		e17|enlightenment)
   1.139 -			WM=enlightenment_start
   1.140 -			XSEVER_OPTS="dpms -terminate" ;;
   1.141 +			WM=enlightenment_start ;;
   1.142  		fluxbox)
   1.143 -			WM=startfluxbox
   1.144 -			XSEVER_OPTS="dpms" ;;
   1.145 +			WM=startfluxbox ;;
   1.146  		dwm|karmen)
   1.147 -			WM=$WM-session
   1.148 -			XSEVER_OPTS="dpms" ;;
   1.149 +			WM=$WM-session ;;
   1.150  		awesome)
   1.151 -			WM=awesome
   1.152 -			XSEVER_OPTS="dpms" ;;
   1.153 +			WM=awesome ;;
   1.154  		xfce|xfce4)
   1.155 -			WM=xfce4-session
   1.156 -			XSEVER_OPTS="dpms -terminate" ;;
   1.157 +			WM=xfce4-session ;;
   1.158  	esac
   1.159  }
   1.160  
   1.161 @@ -338,7 +287,7 @@
   1.162  		$CONFIG
   1.163  }
   1.164  
   1.165 -# ~/.xinitrc for slim login.
   1.166 +# ~/.xinitrc for X login from a DM.
   1.167  creat_xinitrc()
   1.168  {
   1.169  	FILE=$HOME/.xinitrc
   1.170 @@ -348,6 +297,15 @@
   1.171  		cp /etc/slitaz/applications.conf $CONFIG
   1.172  	fi
   1.173  	xinitrc_sample
   1.174 +	# .xinitrc and config for /etc/skel so new added user will get
   1.175 +	# a working X session.
   1.176 +	if test $(id -u) = 0; then
   1.177 +		FILE=/etc/skel/.xinitrc
   1.178 +		CONFIG=/etc/skel/.config/slitaz/applications.conf
   1.179 +		mkdir -p /etc/skel/.config/slitaz
   1.180 +		cp -f /etc/slitaz/applications.conf $CONFIG
   1.181 +		xinitrc_sample
   1.182 +	fi
   1.183  	# In Live mode default user needs a xinitrc, since tazx
   1.184  	# is executed only by root.
   1.185  	if [ ! -f /home/$USER/.xinitrc ]; then
   1.186 @@ -371,19 +329,9 @@
   1.187  	cat > $HOME/.xsession << _EOF_
   1.188  # ~/.xsession: Start X window session manually on your system (startx).
   1.189  #
   1.190 +Xorg &
   1.191 +#xterm &
   1.192  _EOF_
   1.193 -	if [ -x /usr/bin/Xorg ]; then
   1.194 -		echo 'Xorg &' >> $HOME/.xsession
   1.195 -	else
   1.196 -		cat >> $HOME/.xsession << _EOT_
   1.197 -Xvesa -ac -shadow $XSEVER_OPTS \\
   1.198 -	-screen $NEW_SCREEN \\
   1.199 -	-keybd $KEYBD \\
   1.200 -	-mouse $MOUSE &
   1.201 -_EOT_
   1.202 -	fi
   1.203 -	echo '#xterm &' >> $HOME/.xsession
   1.204 -	echo '#xpad &' >> $HOME/.xsession
   1.205  	# LXpanel by default with JWM.
   1.206  	if [ "$WM" = "jwm" ]; then
   1.207  		echo 'lxpanel &' >> $HOME/.xsession
   1.208 @@ -397,22 +345,13 @@
   1.209  ###################
   1.210  
   1.211  case "$1" in
   1.212 -	show-config)
   1.213 -		. /etc/X11/screen.conf
   1.214 -		echo ""
   1.215 -		echo "X11 screen resolution: $SCREEN"
   1.216 -		echo ""
   1.217 -		echo "Slim configuration for X server:"
   1.218 -		cat /etc/slim.conf | grep ^default_xserver
   1.219 -		cat /etc/slim.conf | grep ^xserver_arguments
   1.220 -		echo "" ;;
   1.221  	install-xorg)
   1.222  		# WM can be specified on cmdline.
   1.223  		if [ -n "$2" ]; then
   1.224  			WM=$2
   1.225  		fi
   1.226 +		echo "xorg" > /etc/X11/screen.conf
   1.227  		install_xorg
   1.228 -		slim_config
   1.229  		wm_config
   1.230  		creat_xinitrc
   1.231  		creat_xsession ;;
   1.232 @@ -421,7 +360,7 @@
   1.233  		if [ -n "$2" ]; then
   1.234  			WM=$2
   1.235  		fi
   1.236 -		XSERVER="Xorg"
   1.237 +		echo "xorg" > /etc/X11/screen.conf
   1.238  		wm_config
   1.239  		creat_xinitrc
   1.240  		creat_xsession
   1.241 @@ -431,8 +370,11 @@
   1.242  		if [ -n "$1" ]; then
   1.243  			WM=$1
   1.244  		fi
   1.245 -		[ -n "$NEW_SCREEN" ] || screen_config_dialog
   1.246 -		slim_config
   1.247 +		# User can get a new .xinitrc with tazx from cmdline.
   1.248 +		if test $(id -u) = 0; then
   1.249 +			echo "xorg" > /etc/X11/screen.conf
   1.250 +			screen_config_dialog
   1.251 +		fi
   1.252  		wm_config
   1.253  		creat_xinitrc
   1.254  		creat_xsession ;;