slitaz-tools rev 492

tazx: Update xorg autoconfiguration tool
author Antoine Bodin <gokhlayeh@mailoo.org>
date Mon Jul 05 17:18:20 2010 +0200 (2010-07-05)
parents 423776a7bd8b
children 09ad271f4690
files tinyutils/tazx
line diff
     1.1 --- a/tinyutils/tazx	Mon Jul 05 16:15:05 2010 +0200
     1.2 +++ b/tinyutils/tazx	Mon Jul 05 17:18:20 2010 +0200
     1.3 @@ -23,95 +23,72 @@
     1.4  #  Tazx functions  #
     1.5  ####################
     1.6  
     1.7 -# Patch xorg.conf to set keymap layout.
     1.8 -patch_xorg_kbd()
     1.9 +# Populate xorg.conf.d.
    1.10 +xorg_conf_d()
    1.11  {
    1.12 -	KEYMAP=`cat /etc/keymap.conf`
    1.13 +	# Define the xorg.conf.d (can be /etc/X11/xorg.conf.d or /usr/share/X11/xorg.conf.d)
    1.14 +	xorg_config=/etc/X11/xorg.conf.d
    1.15 +
    1.16 +	# Define the xorg.conf.new place.
    1.17 +	xorg_template=/root/xorg.conf.new
    1.18 +
    1.19 +	# Obtain a default configuration file from Xorg.
    1.20 +	Xorg -configure :1
    1.21 +
    1.22 +	# Put the differents sections in separate files in the configuration directory.
    1.23 +	sed -e '/Section "ServerLayout"/,/EndSection/!d' -e "s/EndSection/EndSection\n/" $xorg_template | grep -v Core > $xorg_config/10-ServerLayout.conf
    1.24 +	sed -e '/Section "Files"/,/EndSection/!d' -e "s/EndSection/EndSection\n/" $xorg_template > $xorg_config/20-Files.conf
    1.25 +	sed -e '/Section "Module"/,/EndSection/!d' -e "s/EndSection/EndSection\n/" $xorg_template > $xorg_config/30-Module.conf
    1.26 +	sed -e '/Section "Monitor"/,/EndSection/!d' -e "s/EndSection/EndSection\n/" $xorg_template > $xorg_config/50-Monitor.conf
    1.27 +	sed -e '/Section "Device"/,/EndSection/!d' -e "s/EndSection/EndSection\n/" $xorg_template > $xorg_config/60-Device.conf
    1.28 +	sed -e '/Section "Screen"/,/EndSection/!d' -e "s/EndSection/EndSection\n/" $xorg_template > $xorg_config/70-Screen.conf
    1.29 +
    1.30 +	# Remove the template.
    1.31 +	rm $xorg_template
    1.32 +
    1.33 +	# Configure the keyboard with the right keymap.
    1.34 +	keymap=`cat /etc/keymap.conf`
    1.35 +	keyboard_config=$xorg_config/40-Keyboard.conf
    1.36 +	echo 'Section "InputClass"
    1.37 +		Identifier "Keyboard Defaults"
    1.38 +		MatchIsKeyboard "yes"' > $keyboard_config
    1.39  	case $KEYMAP in
    1.40  		fr_CH-latin1)
    1.41  			# Swiss FrenCH
    1.42 -			patch -p0 <<EOF
    1.43 ---- /etc/X11/xorg.conf
    1.44 -+++ /etc/X11/xorg.conf
    1.45 -@@ -26,6 +26,8 @@
    1.46 - Section "InputDevice"
    1.47 - 	Identifier  "Keyboard0"
    1.48 - 	Driver      "kbd"
    1.49 -+	Option      "XkbLayout"	 "ch"
    1.50 -+	Option      "XkbVariant" "fr"
    1.51 - EndSection
    1.52 - 
    1.53 - Section "InputDevice"
    1.54 -EOF
    1.55 -			;;
    1.56 +			echo '	Option "XkbLayout" "ch"
    1.57 +		Option "XkbVariant" "fr"' >> $keyboard_config
    1.58 +		;;
    1.59  		en)
    1.60  			# Englisk UK
    1.61 -			patch -p0 <<EOF
    1.62 ---- /etc/X11/xorg.conf
    1.63 -+++ /etc/X11/xorg.conf
    1.64 -@@ -26,6 +26,8 @@
    1.65 - Section "InputDevice"
    1.66 - 	Identifier  "Keyboard0"
    1.67 - 	Driver      "kbd"
    1.68 -+	Option      "XkbLayout"	 "en"
    1.69 -+	Option      "XkbVariant" "en"
    1.70 - EndSection
    1.71 - 
    1.72 - Section "InputDevice"
    1.73 -EOF
    1.74 -			;;
    1.75 +			echo '	Option "XkbLayout" "en"
    1.76 +		Option "XkbVariant" "en"' >> $keyboard_config
    1.77 +		;;
    1.78  		ru)
    1.79  			# Russian
    1.80 -			patch -p0 <<EOF
    1.81 ---- /etc/X11/xorg.conf
    1.82 -+++ /etc/X11/xorg.conf
    1.83 -@@ -26,6 +26,8 @@
    1.84 - Section "InputDevice"
    1.85 - 	Identifier  "Keyboard0"
    1.86 - 	Driver      "kbd"
    1.87 -+	Option      "XkbLayout"	 "us,ru(winkeys)"
    1.88 -+	Option      "XkbVariant" "grp:alt_shift_toggle"
    1.89 - EndSection
    1.90 - 
    1.91 - Section "InputDevice"
    1.92 -EOF
    1.93 -			;;
    1.94 +			echo '	Option "XkbLayout" "us,ru(winkeys)"
    1.95 +		Option "XkbVariant" "grp:alt_shift_toggle"'  >> $keyboard_config
    1.96 +		;;
    1.97  		slovene)
    1.98  			# Slovenian
    1.99 -			patch -p0 <<EOF
   1.100 ---- /etc/X11/xorg.conf
   1.101 -+++ /etc/X11/xorg.conf
   1.102 -@@ -26,6 +26,8 @@
   1.103 - Section "InputDevice"
   1.104 - 	Identifier  "Keyboard0"
   1.105 - 	Driver      "kbd"
   1.106 -+	Option      "XkbLayout"  "si"
   1.107 -+	Option      "XkbOptions" "grp:alt_shift_toggle"
   1.108 - EndSection
   1.109 - 
   1.110 - Section "InputDevice"
   1.111 -EOF
   1.112 -			;;
   1.113 +			echo '	Option "XkbLayout" "si"
   1.114 +		Option "XkbOptions" "grp:alt_shift_toggle"' >> $keyboard_config
   1.115 +		;;
   1.116  		*)
   1.117  			# Use clean /etc/keymap.conf value.
   1.118 -			KEYMAP=${KEYMAP%-latin1}
   1.119 -			KEYMAP=${KEYMAP%-lat2}
   1.120 -			KEYMAP=${KEYMAP%-lat6}
   1.121 -			KEYMAP=${KEYMAP%-abnt2}
   1.122 -			patch -p0 <<EOF
   1.123 ---- /etc/X11/xorg.conf
   1.124 -+++ /etc/X11/xorg.conf
   1.125 -@@ -26,6 +26,7 @@
   1.126 - Section "InputDevice"
   1.127 - 	Identifier  "Keyboard0"
   1.128 - 	Driver      "kbd"
   1.129 -+	Option      "XkbLayout" "$KEYMAP"
   1.130 - EndSection
   1.131 - 
   1.132 - Section "InputDevice"
   1.133 -EOF
   1.134 +			keymap=${keymap%-latin1}
   1.135 +			keymap=${keymap%-lat2}
   1.136 +			keymap=${keymap%-lat6}
   1.137 +			keymap=${keymap%-abnt2}
   1.138 +			echo '	Option "XkbLayout" "'$keymap\"  >> $keyboard_config
   1.139  		;;
   1.140  	esac
   1.141 +
   1.142 +	echo 'Endsection' >> $keyboard_config
   1.143 +
   1.144 +	# Create a xorg.conf if needed.
   1.145 +	[ ! -f /etc/X11/xorg.conf ] && echo "# You can put here you're own Xorg configurations.
   1.146 +	# This configuration file is readed before all files in /etc/X11/xorg.conf.d
   1.147 +	# This file will not be erased by next updates." > /etc/X11/xorg.conf
   1.148  }
   1.149  
   1.150  # Install xorg server
   1.151 @@ -146,9 +123,7 @@
   1.152  		*)
   1.153  			tazpkg get-install xorg-server
   1.154  			tazpkg get-install xorg-xf86-video-$value
   1.155 -			Xorg -configure :1
   1.156 -			mv -f /root/xorg.conf.new /etc/X11/xorg.conf
   1.157 -			patch_xorg_kbd
   1.158 +			xorg_conf_d
   1.159  			sed -i 's|/usr/bin/Xvesa|/usr/bin/Xorg|' /etc/slim.conf
   1.160  			sed -i s/"^xserver_arguments"/'\#xserver_arguments'/ /etc/slim.conf
   1.161  			XSERVER=Xorg ;;
   1.162 @@ -443,7 +418,7 @@
   1.163  		wm_config
   1.164  		creat_xinitrc
   1.165  		creat_xsession
   1.166 -		patch_xorg_kbd ;;
   1.167 +		xorg_conf_d ;;
   1.168  	*)
   1.169  		# WM can be specified on cmdline.
   1.170  		if [ -n "$1" ]; then