improve some other setuptool
[cmdllinux.git] / scripts / setup / setxorgkeymap
blob83c88b05f3f03dc7fe107a63bf5c83b8a7c57c10
1 #! /bin/sh
3 : ${DIALOG=dialog}
5 tempfile=`mktemp 2> /dev/null` || tempfile=/tmp/test$$
6 trap "rm -f $tempfile" 0 1 2 5 15
8 #conf_key=XkbLayout
9 conf_key=xkb_layout
10 #conf_file=/etc/X11/xorg.conf.d/00-keyboard.conf
11 conf_file=/etc/X11/xorg.conf.d/90-inputclass-setting.conf
13 [ -r /usr/share/X11/xkb/rules/evdev.lst -a -e $conf_file ] || exit 0
15 list_keymaps(){
16 LN1=`expr $(grep -n "^! layout" /usr/share/X11/xkb/rules/evdev.lst | cut -d : -f 1) + 1`
17 LN2=`expr $(grep -n "^! variant" /usr/share/X11/xkb/rules/evdev.lst | cut -d : -f 1) - 2`
18 sed -n "${LN1},${LN2}p" /usr/share/X11/xkb/rules/evdev.lst | \
19 while read MAP DESC; do
20 case $MAP in
21 nec_*) echo "jp ${DESC// /_} off";;
22 *) echo "$MAP ${DESC// /_} off";;
23 esac
24 done
27 $DIALOG --backtitle "Configuring system settings" \
28 --title "" --clear \
29 --radiolist "Select Xkeyboard layout" 20 61 15 \
30 `list_keymaps | sort` 2> $tempfile
32 retval=$?
34 choice=`cat $tempfile`
35 case $retval in
37 if [ -z $choice ]; then
38 sed -i "s%.*Option.*\"$conf_key\".*%# Option \"$conf_key\" \"us\"%" $conf_file
39 else
40 sed -i "s%.*Option.*\"$conf_key\".*% Option \"$conf_key\" \"$choice\"%" $conf_file
44 #cancel pressed
46 255)
47 #ESC pressed
49 esac