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 ################################################################################
13 # shellcheck disable=SC1091
14 . /etc/grml/script-functions
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"
24 echo "$1=${2}" >> "$CONFFILE"
30 case "$2" in *$1*) return 0;; esac
34 # Reread boot command line; echo last parameter's argument or return false.
36 stringinstring " $1=" "$CMDLINE" || return 1
37 result="${CMDLINE##*$1=}"
38 result="${result%%[ ]*}"
43 # shellcheck disable=SC1091
44 [ -r /etc/sysconfig/keyboard ] && . /etc/sysconfig/keyboard
46 [ -n "$KEYTABLE" ] && DEFAULT_KEYBOARD="$KEYTABLE"
47 if [ -z "$DEFAULT_KEYBOARD" ] ; then
48 DEFAULT_KEYBOARD="$(getbootparam lang 2>/dev/null)"
49 if [ -z "$DEFAULT_KEYBOARD" ] ; then
54 # shellcheck disable=SC1010
56 LANGUAGE=$(LANG=C $DIALOG --stdout --title "$PN" --default-item $DEFAULT_KEYBOARD --radiolist \
57 "Which keyboard layout do you want to use?
59 Please notice that this will not really affect your currently running system.
60 If you want to change keyboard settings temporarily please use grml-lang instead.
62 Configuration will be written to /etc/sysconfig/keyboard" 0 0 0 \
66 cf "french canadian" off \
74 en "english [us] (default)" on \
89 tw "chinese (traditional)" off \
99 (1) echo "Cancel pressed." ; exit 1 ;;
100 (255) echo "ESC pressed." ; exit 1 ;;
103 # read in the file where all the $LANGUAGE stuff is defined
104 # shellcheck disable=SC1091
105 . /etc/grml/language-functions
107 cat > /etc/sysconfig/keyboard <<EOF
108 # File generated by $PN on $(date)
110 XKEYBOARD="$XKEYBOARD"
111 KDEKEYBOARD="$KDEKEYBOARD"
112 KDEKEYBOARDS="$KDEKEYBOARD"
119 LANG=C $DIALOG --stdout --msgbox "Writing keyboard settings ($KEYTABLE) to /etc/sysconfig/keyboard was successful." 0 0
122 LANG=C $DIALOG --stdout --msgbox "Error writing settings for $KEYTABLE to /etc/sysconfig/keyboard." 0 0
126 ## END OF FILE #################################################################