slitaz-tools rev 1018

tinyutils/tazx: do not override saved user settings on LXPanel (don't add/remove "xkb" applet)
author Aleksej Bobylev <al.bobylev@gmail.com>
date Tue Apr 11 02:28:50 2017 +0300 (2017-04-11)
parents ff7076d04f2e
children c368cf4a87d5
files tinyutils/tazx
line diff
     1.1 --- a/tinyutils/tazx	Tue Mar 14 02:36:18 2017 +0200
     1.2 +++ b/tinyutils/tazx	Tue Apr 11 02:28:50 2017 +0300
     1.3 @@ -1,10 +1,10 @@
     1.4  #!/bin/sh
     1.5  #
     1.6  # Tazx - Ncurses X configuration for SliTaz GNU/Linux using Dialog boxes.
     1.7 -# This tinyutil is part of slitaz-tools. Tazx can configure Xorg with
     1.8 +# This tiny util is part of slitaz-tools. Tazx can configure Xorg with
     1.9  # several Window Managers. The GTK interface to configure X is in tazbox.
    1.10  #
    1.11 -# (c) 2011-2015 SliTaz GNU/Linux - GNU GPL v3.
    1.12 +# (c) 2011-2017 SliTaz GNU/Linux - GNU GPL v3.
    1.13  # Authors: Christophe Lincoln <pankso@slitaz.org>
    1.14  #          Pascal Bellard <pascal.bellard@slitaz.org>
    1.15  #
    1.16 @@ -45,7 +45,7 @@
    1.17  
    1.18  gen_xorg_conf_file() {
    1.19  	if [ ! -f /etc/X11/xorg.conf ]; then
    1.20 -		cat > /etc/X11/xorg.conf << EOT
    1.21 +		cat > /etc/X11/xorg.conf <<EOT
    1.22  # You can put here your own Xorg configurations. This config file is read
    1.23  # before all files in /etc/X11/xorg.conf.d and will NOT be erased by any
    1.24  # updates.
    1.25 @@ -54,84 +54,10 @@
    1.26  }
    1.27  
    1.28  
    1.29 -# Add or remove xkb applet from lxpanel
    1.30 -
    1.31 -xkb() {
    1.32 -	case $(id -u) in
    1.33 -		0)
    1.34 -			# Empty if lxpanel not running, else something like:
    1.35 -			# tux lxpanel -p slitaz
    1.36 -			LXPS=$(ps -ouser,args | sed -n '/[l]xpanel/ s|  *| |p' | \
    1.37 -				fgrep -v '[' | fgrep -v 'xkb' | fgrep -v 'sh')
    1.38 -
    1.39 -			# Stop lxpanel
    1.40 -			if [ -n "$LXPS" ]; then
    1.41 -				lxpanelctl exit
    1.42 -				killall lxpanel
    1.43 -			fi
    1.44 -
    1.45 -			# For all human users
    1.46 -			for USER in $(awk -F: '/\/home\//{print $1}' /etc/passwd); do
    1.47 -				su $USER -c '. ~/.profile; tazx xkb'
    1.48 -			done
    1.49 -
    1.50 -			# Re-run lxpanel
    1.51 -			[ -n "$LXPS" ] && su ${LXPS%% *} -c "exec ${LXPS#* }" &
    1.52 -			;;
    1.53 -
    1.54 -		*)
    1.55 -			DOTCONFIG=${XDG_CONFIG_HOME:-$HOME/.config}
    1.56 -			CFG_LXPANEL=$DOTCONFIG/lxpanel
    1.57 -
    1.58 -			if [ ! -d $CFG_LXPANEL ]; then
    1.59 -				mkdir -p $DOTCONFIG
    1.60 -				cp -r /etc/lxpanel $DOTCONFIG
    1.61 -			fi
    1.62 -
    1.63 -			case $(fgrep 'XkbLayout' /etc/X11/xorg.conf.d/40-Keyboard.conf | \
    1.64 -				fgrep -o ',') in
    1.65 -				'')
    1.66 -					for CFG in $(find $CFG_LXPANEL -type f -name panel); do
    1.67 -						if [ -n "$(grep 'type *= *xkb' $CFG)" ]; then
    1.68 -							echo "Remove xkb applet from $CFG"
    1.69 -							sed -i "$(grep -n -e "^Plugin {" -e "^}" -e "xkb" \
    1.70 -								$CFG | grep -C 1 xkb | grep -v xkb | cut -d: \
    1.71 -								-f1 | tr '\n' ' ' | sed 's| |,|')d" $CFG
    1.72 -						fi
    1.73 -					done ;;
    1.74 -				',')
    1.75 -					for CFG in $(find $CFG_LXPANEL -type f -name panel); do
    1.76 -						if [ -z "$(grep 'type *= *xkb' $CFG)" ]; then
    1.77 -							echo "Add xkb applet to $CFG"
    1.78 -							XKB='Plugin {\
    1.79 -    type = xkb\
    1.80 -    Config {\
    1.81 -        DisplayType=1\
    1.82 -        PerWinLayout=0\
    1.83 -        NoResetOpt=0\
    1.84 -        KeepSysLayouts=1\
    1.85 -        Model=pc105\
    1.86 -        LayoutsList=us\
    1.87 -        VariantsList=,\
    1.88 -        ToggleOpt=shift_caps_toggle\
    1.89 -        FlagSize=4\
    1.90 -    }\
    1.91 -}\
    1.92 -'
    1.93 -							sed -i "$(grep -n -e "^Plugin {" -e "tray" $CFG | \
    1.94 -								grep -B1 tray | head -n1 | cut -d: -f1) i\\
    1.95 -$XKB" $CFG
    1.96 -						fi
    1.97 -					done ;;
    1.98 -			esac ;;
    1.99 -	esac
   1.100 -}
   1.101 -
   1.102 -
   1.103  # Generate or regenerate 40-Keyboard.conf
   1.104  
   1.105  keyboard_conf() {
   1.106 -	# Configure the keyboard with the right keymap
   1.107 +	# Configure the keyboard with the correct keymap
   1.108  	keymap=$(cat /etc/keymap.conf)
   1.109  	keyboard_config="/etc/X11/xorg.conf.d/40-Keyboard.conf"
   1.110  	variant=""
   1.111 @@ -204,7 +130,7 @@
   1.112  		update_conf='1'
   1.113  	fi
   1.114  
   1.115 -	[ -n "$update_conf" ] && cat > $keyboard_config << EOC
   1.116 +	[ -n "$update_conf" ] && cat > $keyboard_config <<EOC
   1.117  Section "InputClass"
   1.118  	Identifier "Keyboard Defaults"
   1.119  	MatchIsKeyboard "yes"
   1.120 @@ -216,7 +142,6 @@
   1.121  
   1.122  	status
   1.123  	[ -z "$variant" ] && sed -i '/XkbVariant/d' $keyboard_config
   1.124 -	[ -z $(busybox which lxpanel) ] || xkb
   1.125  }
   1.126  
   1.127  
   1.128 @@ -233,7 +158,7 @@
   1.129  	Xorg -configure :2
   1.130  
   1.131  	# Backup existing config.
   1.132 -	tar -cf $xorg_config/../Previous_xorg.conf.d.tar $xorg_config/ &> /dev/null
   1.133 +	tar -cf $xorg_config/../Previous_xorg.conf.d.tar $xorg_config/ &>/dev/null
   1.134  
   1.135  	# Put the different sections in separate files in the config directory.
   1.136  	save_chunk 10-ServerLayout
   1.137 @@ -601,10 +526,6 @@
   1.138  		proc_cmdline
   1.139  		set_depth $2 ;;
   1.140  
   1.141 -	xkb)
   1.142 -		xkb ;;
   1.143 -
   1.144 -
   1.145  	*help|-h|-?)
   1.146  		emsg "
   1.147  <b>tazx</b> - $(_ 'Configuration tool for SliTaz GNU/Linux')