bt-audio: check for presence of snd-bt-sco
[grml-scripts.git] / usr_sbin / grml-setkeyboard
1 #!/bin/sh
2 # Filename:      grml-setkeyboard
3 # Purpose:       set keyboard layout system-wide on grml system
4 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2.
7 # Latest change: Mit Sep 05 19:06:41 CEST 2007 [mika]
8 ################################################################################
9
10 PN="$(basename $0)"
11 DIALOG=dialog
12 CMDLINE=/proc/cmdline
13
14 . /etc/grml/script-functions
15
16 check4root || exit 1
17
18 setvalue(){
19   [ -n "$2" ] || return 1
20   # already present in conffile?
21   if grep -q ${1} $CONFFILE ; then
22      sed -i "s#^${1}.*#${1}=${2}#"   $CONFFILE
23   else
24      echo "$1=${2}" >> $CONFFILE
25   fi
26 }
27
28 # same for strings
29 stringinstring(){
30   case "$2" in *$1*) return 0;; esac
31   return 1
32 }
33
34 # Reread boot command line; echo last parameter's argument or return false.
35 getbootparam(){
36   stringinstring " $1=" "$CMDLINE" || return 1
37   result="${CMDLINE##*$1=}"
38   result="${result%%[   ]*}"
39   echo "$result"
40   return 0
41 }
42
43 [ -r /etc/sysconfig/keyboard ] && . /etc/sysconfig/keyboard
44
45 [ -n "$KEYTABLE" ] && DEFAULT_KEYBOARD="$KEYTABLE"
46 if [ -z "$DEFAULT_KEYBOARD" ] ; then
47   DEFAULT_KEYBOARD="$(getbootparam lang 2>/dev/null)"
48   if [ -z "$DEFAULT_KEYBOARD" ] ; then
49     DEFAULT_KEYBOARD=en
50   fi
51 fi
52
53 LANGUAGE=$(LANG=C $DIALOG --stdout --title "$PN" --default-item $DEFAULT_KEYBOARD --radiolist \
54 "Which keyboard layout do you want to use?
55
56 Please notice that this will not really affect your currently running system.
57 If you want to change keyboard settings temporarly please use grml-lang instead.
58
59 Configuration will be written to /etc/sysconfig/keyboard" 0 0 0 \
60  at  austrian off \
61  be  belgian off \
62  bg  bulgarian off \
63  cf  "french canadian" off \
64  ch  swiss off \
65  cn  chinese off \
66  cs  czech off \
67  cz  czech off \
68  da  da off \
69  de  german   off \
70  dk  dansk off \
71  en  "english [us] (default)" on \
72  es  spanish off \
73  fi  finnish off \
74  fr  french off \
75  he  hebrew off \
76  ie  irish off \
77  il  hebrew off \
78  it  italian off \
79  ja  japanese off \
80  nl  dutch off \
81  pl  polish off \
82  ru  russian off \
83  sk  slovak off \
84  sl  slovenian off \
85  tr  turkish off \
86  tw  "chinese (traditional)" off \
87  uk  british off \
88 )
89
90 retval=$?
91 case $retval in
92     (0)
93           # everything ok
94           ;;
95     (1)   echo "Cancel pressed." ; exit 1 ;;
96     (255) echo "ESC pressed."    ; exit 1 ;;
97 esac
98
99 # read in the file where all the $LANGUAGE stuff is defined
100   source /etc/grml/language-functions
101
102 cat > /etc/sysconfig/keyboard <<EOF
103 # File generated by $PN on $(date)
104 KEYTABLE="$KEYTABLE"
105 XKEYBOARD="$XKEYBOARD"
106 KDEKEYBOARD="$KDEKEYBOARD"
107 KDEKEYBOARDS="$KDEKEYBOARD"
108 EOF
109
110 retval=$?
111 case $retval in
112     (0)
113           # everything ok
114           LANG=C $DIALOG --stdout --msgbox "Writing keyboard settings ($KEYTABLE) to /etc/sysconfig/keyboard was successful." 0 0
115           ;;
116     *)
117           LANG=C $DIALOG --stdout --msgbox "Error writing settings for $KEYTABLE to /etc/sysconfig/keyboard." 0 0
118           ;;
119 esac
120
121 ## END OF FILE #################################################################