slitaz-tools diff tinyutils/tazx @ rev 912

tazx: add default applications dialog, replace lists from tazbox.
author Xander Ziiryanoff <psychomaniak@xakep.ru>
date Wed Nov 05 19:01:28 2014 +0200 (2014-11-05)
parents f582b09fa62b
children 5bb075010572
line diff
     1.1 --- a/tinyutils/tazx	Sun Oct 05 23:54:36 2014 +0000
     1.2 +++ b/tinyutils/tazx	Wed Nov 05 19:01:28 2014 +0200
     1.3 @@ -133,6 +133,16 @@
     1.4  	gen_xorg_conf_file
     1.5  }
     1.6  
     1.7 +dialog_end() {
     1.8 +	retval=$?
     1.9 +	exec 3>&-
    1.10 +	# Continue or exit.
    1.11 +	case $retval in
    1.12 +		0) continue ;;
    1.13 +		1|255) exit 0 ;;
    1.14 +	esac
    1.15 +}
    1.16 +
    1.17  # Install xorg server.
    1.18  install_xorg() {
    1.19  	[ -f "/var/lib/tazpkg/packages.list" ] || tazpkg recharge
    1.20 @@ -145,33 +155,97 @@
    1.21  		while read x; do echo $x; _ 'driver'; done) \
    1.22  	"quit" "$(_n 'Quit')" \
    1.23  	2>&1 1>&3)
    1.24 -	retval=$?
    1.25 -	exec 3>&-
    1.26 -
    1.27 -	# Continue or exit.
    1.28 -	case $retval in
    1.29 -		0) continue ;;
    1.30 -		1|255) exit 0 ;;
    1.31 -	esac
    1.32 +	dialog_end
    1.33  
    1.34  	# Set selected value.
    1.35  	case $value in
    1.36  		quit) exit 0 ;;
    1.37  		*)
    1.38 -			[ -d "$installed/xorg-server" ] || tazpkg -gi xorg-server
    1.39 -			[ -d "$installed/xorg-xf86-video-$value" ] || \
    1.40 -				tazpkg -gi xorg-xf86-video-$value
    1.41 +			inst_pkg xorg-server
    1.42 +			inst_pkg xorg-xf86-video-$value
    1.43  			xorg_conf_d ;;
    1.44  	esac
    1.45  }
    1.46  
    1.47 -install_slim() {
    1.48 -	[ -d "$installed/slim" ] || tazpkg -gi slim
    1.49 -	[ -d "$installed/dbus" ] || tazpkg -gi dbus
    1.50 +inst_pkg() {
    1.51 +	CMD="sudo tazpkg -gi $@"
    1.52 +	test $(id -u) = 0 && CMD="tazpkg -gi $@"
    1.53 +	[ -d "$installed/$@" ] || $CMD
    1.54  }
    1.55  
    1.56 -# Screen configuration dialog. TODO: menus items to enable/disable X on boot
    1.57 -# and sed /etc/rcS.conf to remove slim from RUN_DAEMONS.
    1.58 +apps_dialog() {
    1.59 +	. ${user_conf}
    1.60 +	exec 3>&1
    1.61 +	app=$($DIALOG --clear --colors \
    1.62 +		--extra-label "$(_n 'Edit')" \
    1.63 +		--backtitle "{ $(_n '\Z3SliTaz applications config\Zn') }" \
    1.64 +		--inputmenu " " 22 52 18 WINDOW_MANAGER $WINDOW_MANAGER \
    1.65 +	$(for a in EDITOR BROWSER TERMINAL FILE_MANAGER; do
    1.66 +		eval n=$"$a" ; echo "$a $n";
    1.67 +	done) 2>&1 1>&3)
    1.68 +	dialog_end
    1.69 +	case $app in
    1.70 +		RENAMED*)
    1.71 +			appname=$(echo $app | cut -d " " -f3)
    1.72 +			app=$(echo $app | cut -d " " -f2) ;;
    1.73 +		*)
    1.74 +			app_name_dialog only-installed d a-item ;;
    1.75 +	esac
    1.76 +	if [ ! $appname = " " ]; then
    1.77 +		[ ! $appname = show_ALL ] || app_name_dialog full-list d
    1.78 +		if [ ! $(busybox which ${appname} 2>/dev/null) ]; then
    1.79 +			inst_pkg $appname
    1.80 +			if [ ! -d "$installed/$appname" ]; then
    1.81 +			pknm=$(tazpkg search-pkgname /bin/$appname \
    1.82 +			| grep -Ev '=|:| |/bin/')
    1.83 +			inst_pkg $pknm
    1.84 +			fi
    1.85 +		else
    1.86 +		sed '/'${app}'/s|=.*$|="'${appname}'"|' -i ${user_conf}
    1.87 +		fi
    1.88 +	fi
    1.89 +	apps_dialog
    1.90 +}
    1.91 +
    1.92 +app_name_dialog() {
    1.93 +	bt="" sz=28 ; [ $1 = full-list ] || sz=20 \
    1.94 +	bt=$(_n 'select "Show_ALL" to install additional programs')
    1.95 +	exec 3>&1
    1.96 +	appname=$($DIALOG --clear --colors \
    1.97 +	--backtitle "\Z1${bt}\Zn" --title "${app}" \
    1.98 +	--menu "" $sz 50 24 $(gen_applist $app $@) 2>&1 1>&3) \
    1.99 +	dialog_end
   1.100 +}
   1.101 +
   1.102 +gen_applist() {
   1.103 +. ${user_conf}
   1.104 +FILE_MANAGERS=" clex caja emelfm2 mc pathfinder pcmanfm pcmanfm-qt ranger spacefm thunar xfe ytree"
   1.105 +BROWSERS=" arora chrome cream dillo elinks firefox iron links lynx midori netsurf \
   1.106 + opera QtWeb qupzilla retawq seamonkey surf tazweb"
   1.107 +EDITORS=" adie beaver emacs geany jed joe juffed ht le leafpad mcedit mousepad mp-5 \
   1.108 + nano qedit SciTE vi vim xedit xfw zile"
   1.109 +TERMINALS=" aterm evilvte lxterminal mrxvt qterminal sakura stjerm tilda urxvt vte \
   1.110 + xterm yeahconsole"
   1.111 +WINDOW_MANAGERS=" awesome blackbox dwm echinus enlightenment fluxbox icewm-session jwm \
   1.112 + lxde-session karmen matchbox openbox-session pekwm ratpoison startlxqt xfwm4"
   1.113 +
   1.114 +	eval list='$'"$1"S
   1.115 +	eval current='$'"$1"
   1.116 +for i in $current $(echo $list" " | sed "s| "$current" | |g") $4 ; do
   1.117 +	t="<--" ; [ $(busybox which $i 2>/dev/null) ] || t=---
   1.118 +	if [ $2 = only-installed ] && [ $t = --- ]; then
   1.119 +		case $i in
   1.120 +		a-item) i=show_ALL t=$(_n 'Get more apps') ;;
   1.121 +		*) i=" " t=" " ;; esac
   1.122 +	fi
   1.123 +	instmsg=$(_n 'install')
   1.124 +	t=$(echo $t | sed "s|---|$instmsg|g ; s| |_|g")
   1.125 +	echo "$i"
   1.126 +	[ $3 = yad ] || echo -e "$t"
   1.127 +done
   1.128 +}
   1.129 +
   1.130 +# Screen configuration dialog.
   1.131  config_dialog() {
   1.132  	. /etc/rcS.conf ; LM="ON"
   1.133  	[ $LOGIN_MANAGER = "slim" ] || LM="OFF"
   1.134 @@ -185,43 +259,34 @@
   1.135  	"xorg-light"  "$(_n 'Install Xorg server (light version)')" \
   1.136  	"onboot"      "$(_n 'AutoStart Xorg by SLiM on boot') ...| $LM" \
   1.137  	"slim"        "$(_n '(Re)Start Simple Login Manager now')" \
   1.138 +	"wm_apps"     "$(_n 'Select & install WM|DE + applications')" \
   1.139  	"quit"        "$(_n 'Quit Tazx utility')" \
   1.140  	2>&1 1>&3)
   1.141 -	retval=$?
   1.142 -	exec 3>&-
   1.143 -
   1.144 -	# Continue or exit.
   1.145 -	case $retval in
   1.146 -		0) continue ;;
   1.147 -		1|255) exit 0 ;;
   1.148 -	esac
   1.149 -
   1.150 +	dialog_end
   1.151  	# Set selected value.
   1.152  	case "$value" in
   1.153 -		xorg) 
   1.154 +		xorg)
   1.155  			install_xorg ;;
   1.156  		xorg-light)
   1.157 -			[ -d "$installed/xorg-server-light" ] || \
   1.158 -				tazpkg -gi xorg-server-light
   1.159 -			[ -d "$installed/xorg-xf86-video-fbdev" ] || \
   1.160 -				tazpkg -gi xorg-xf86-video-fbdev
   1.161 +			inst_pkg xorg-server-light
   1.162 +			inst_pkg xorg-xf86-video-fbdev
   1.163  			xorg_conf_d ;;
   1.164  		onboot)
   1.165 -			install_slim
   1.166 +			inst_pkg slim ; inst_pkg dbus
   1.167  			if [ $LM = "OFF" ] ; then
   1.168  				LM=slim
   1.169 -			else
   1.170 -				LM=""
   1.171 +			else	LM=""
   1.172  			fi
   1.173 -			sed '/LOGIN_MANAGER=/s|"\([^"]*\)"|"'$LM'"|' \
   1.174 -				-i /etc/rcS.conf
   1.175 -
   1.176 +			sed '/LOGIN_MANAGER/s|=.*$|="'$LM'"|' -i /etc/rcS.conf
   1.177  			[ $LM = "slim" ] || LM=disabled
   1.178  			echo "start X on boot:" $(boldify $LM) ;;
   1.179  		slim)
   1.180 -			install_slim
   1.181 -			[ ! -z $XAUTHORITY ] || \
   1.182 -				stopd slim ; sleep 1 ; startd slim ;;
   1.183 +			inst_pkg slim ; inst_pkg dbus
   1.184 +			[ ! -z $XAUTHORITY ] || stopd slim ;sleep 2; startd slim ;;
   1.185 +		wm_apps)
   1.186 +			slitaz_apps_conf
   1.187 +			. ${user_conf}
   1.188 +			apps_dialog ;;
   1.189  		*)
   1.190  			exit 0 ;;
   1.191  	esac
   1.192 @@ -235,8 +300,9 @@
   1.193  	apps_conf=/etc/slitaz/applications.conf
   1.194  	
   1.195  	if [ "$(id -u)" = 0 ]; then
   1.196 -		user_conf="/etc/skel/.config/slitaz/applications.conf"
   1.197 -		mkdir -p $(dirname $user_conf); cp -f ${apps_conf} ${user_conf}
   1.198 +		user_conf=${apps_conf}
   1.199 +		new_user_conf="/etc/skel/.config/slitaz/applications.conf"
   1.200 +		mkdir -p $(dirname $user_conf); cp -f ${apps_conf} ${new_user_conf}
   1.201  	else
   1.202  		# If started by: startx and with boot opts screen=text
   1.203  		user_conf="$HOME/.config/slitaz/applications.conf"
   1.204 @@ -279,12 +345,18 @@
   1.205  	
   1.206  	*help) 
   1.207  		echo "Usage: $(basename $0) [install-xorg|config-xorg|init|keyboard]" ;;
   1.208 +		
   1.209  	
   1.210 +	get-applist)
   1.211 +		slitaz_apps_conf
   1.212 +		gen_applist $2 $3 $4 ;;
   1.213  	*)
   1.214  		# User can get a new .xinitrc with tazx from cmdline.
   1.215 -		[ $(id -u) == 0 ] && config_dialog
   1.216 -		slitaz_apps_conf
   1.217 -		gen_xsession ;;
   1.218 +		if [ $(id -u) == 0 ]; then config_dialog
   1.219 +		else	slitaz_apps_conf ; apps_dialog
   1.220 +		fi
   1.221 +		# gen_xsession
   1.222 +		;;
   1.223  esac
   1.224  
   1.225  exit 0