#!/bin/sh # Set keymap and xkeymap usage() { cat<< EOF vkmapset - set keymap for console and x-window usage: vkmapset [keymap_name] EOF } vdir=`dirname $0` . $vdir/vasm-functions check_root set_keymap() { cat << EOF > /etc/rc.d/rc.keymap #!/bin/sh # /etc/rc.d/rc.keymap # Made by vkmapset on `date '+%a %b %e %Y'` # This file is called from: /etc/rc.d/rc.M if [ -x /usr/bin/loadkeys ]; then # You may load another keyboard keymap e.g. 'loadkeys fr' = french etc. # The keymaps are in the /usr/lib/kbd/keymaps/i386 directory. loadkeys $MAPNAME # This is so you can open other consoles using the left-[Alt] & [Up]-arrow key. echo "alt keycode 103 = Spawn_Console" | /usr/bin/loadkeys fi EOF chmod +x /etc/rc.d/rc.keymap } unset_keymap() { chmod -x /etc/rc.d/rc.keymap } set_xorg() { ## Change KEYBOARD_MAP sed -i \ s"! Option \"XkbLayout\".*! Option \"XkbLayout\" \"$MAPNAME\"!" \ $1 } set_xkeymap() { echo "XKEYBOARD=\"$MAPNAME\"" >> /etc/sysconfig/vlocity if [ -f /etc/X11/xorg.conf.d/90-keyboard-layout.conf ]; then set_xorg /etc/X11/xorg.conf.d/90-keyboard-layout.conf elif [ -f /usr/share/X11/xorg.conf.d/90-keyboard-layout.conf ]; then cp /usr/share/X11/xorg.conf.d/90-keyboard-layout.conf /etc/X11/xorg.conf.d/90-keyboard-layout.conf set_xorg /etc/X11/xorg.conf.d/90-keyboard-layout.conf else cat << EOF > /etc/X11/xorg.conf.d/90-keyboard-layout.conf Section "InputClass" Identifier "keyboard-all" MatchIsKeyboard "on" MatchDevicePath "/dev/input/event*" Driver "evdev" Option "XkbLayout" "us" #Option "XkbVariant" "" Option "XkbOptions" "terminate:ctrl_alt_bksp" EndSection EOF set_xorg /etc/X11/xorg.conf.d/90-keyboard-layout.conf fi } menu_kmap() { while [ 0 ]; do $DCMD --backtitle "$BACKTITLE" --title "KEYBOARD MAP SELECTION" --menu "\n This menu set keyboard mapping for the text console.\n Please select one of the following keyboard maps:" \ 20 60 11 \ "DEFAULT" "system default (US)" \ "ANSI-dvorak" "Dvorak layout" \ "azerty" "azerty layout" \ "be-latin1" "Belgian" \ "be2-latin1" "" \ "bg" "Bulgarian" \ "bg-cp1251" "" \ "br-abnt" "Brazilian" \ "br-abnt2" "" \ "br-latin1-abnt2" "" \ "br-latin1-us" "" \ "by" "Belarus" \ "cf" "French Canadian" \ "croat" "Croatian" \ "cz-cp1250" "Czech" \ "cz-lat2-prog" "" \ "cz-lat2" "" \ "cz-us-qwertz" "" \ "de" "German" \ "de-latin1-nodeadkeys" "" \ "de-latin1" "" \ "defkeymap" "default" \ "defkeymap_V1.0" "" \ "dk" "Danish" \ "dk-latin1" "" \ "dvorak" "Dvorak" \ "dvorak-l" "Left-handed" \ "dvorak-r" "Right-handed" \ "emacs" "Emacs editor" \ "emacs2" "" \ "es" "Spanish" \ "es-cp850" "" \ "et-nodeakeys" "" \ "et" "" \ "fi-latin1" "Finnish" \ "fi-latin9" "" \ "fi" "" \ "fr_CH-latin1" "French" \ "fr_CH" "" \ "fr-latin0" "" \ "fr-latin1" "" \ "fr-pc" "" \ "fr" "" \ "gr-pc" "Greek" \ "gr" "" \ "hebrew" "" \ "hu101" "Hungarian" \ "hu" "" \ "hypermap.m4" "for the adventurous soul..." \ "il-heb" "hebrew?..." \ "il-phonetic" "" \ "is-latin1" "Icelandic" \ "it-ibm" "Italian" \ "it" "" \ "it2" "" \ "jp106" "Japanese" \ "la-latin1" "Lao's people" \ "lt" "Lithuanian" \ "lt-baltic" "" \ "lt.l4" "" \ "mk" "Macedonian" \ "mk-cp1251" "" \ "mk-utf" "" \ "mk0" "" \ "nl" "IBM 85 key" \ "nl2" "IBM 102 key Eurosign no-deadkeys" \ "no-latin1" "Norwegian" \ "no" "" \ "pc110" "" \ "pc-dvorak-latin1" "" \ "pl" "Polish" \ "pl2" "" \ "pt-latin1" "" \ "pt-latin9" "" \ "pt-old" "" \ "ro" "Romanian" \ "ru-cp1251" "Russian" \ "ru-ms" "" \ "ru-yawerty" "" \ "ru" "" \ "ru1" "" \ "ru2" "" \ "ru3" "" \ "ru4" "" \ "ru_win" "" \ "se-latin1" "Swedish" \ "se-fi-ir209" "" \ "se-fi-lat6" "" \ "se-ir209" "" \ "se-lat6" "" \ "sf-latin1" "" \ "sf" "" \ "sg" "Singapore" \ "sg-latin1-lk450" "" \ "sg-latin1" "" \ "sk-prog-qwerty" "Slovakian" \ "sk-prog-qwertz" "" \ "sk-prog" "" \ "sk-qwerty" "" \ "sk-qwertz" "" \ "slovene" "" \ "speakupmap" "keymap for the JFW screenreader" \ "sr-cy" "Suriname" \ "sv-latin1" "El Salvador" \ "tralt" "Turkish" \ "tr_f-latin5" "" \ "trf" "" \ "tr_q-latin5" "" \ "tralt" "" \ "trq" "" \ "ua-utf-ws" "Ukrainian" \ "ua-utf" "" \ "ua-ws" "" \ "ua" "" \ "uk" "United-Kingdom" \ "unicode" "" \ "us-acentos" "US-hispanic? beats me..." \ "us" "USA" \ "wangbe" "Belgium" \ "wangbe2" "" \ "windowkeys" "you bet" \ 2> $freply || exit $? MAPNAME="`cat $freply`" if [ "$MAPNAME" = "DEFAULT" ]; then infobox "Setting keymap to default" "KEYMAP" MAPNAME="us" unset_keymap set_xkeymap sleep 2 clean_exit 0 fi if ! loadkeys $MAPNAME 1>/dev/null 2>$fmenu; then $DCMD --backtitle "$BACKTITLE" --title "LOADKEYS ERROR" msgbox \ "`cat $fmenu`" 10 62 2>/dev/null continue; fi ## Testing .. while [ 0 ]; do $DCMD --title "KEYBOARD TEST" --inputbox \ "OK, the new map is now installed. You may now test it by typing \ anything you want. To quit testing the keyboard, enter 1 on a \ line by itself to accept the map and exit, or 2 on a line by \ itself to reject the current keyboard map and select a new one." \ 11 70 2> $freply if [ $? = 1 ]; then break; fi REPLY="`cat $freply`" if [ "$REPLY" = "1" ]; then infobox "Setting keymap to $MAPNAME" "KEYMAP" set_keymap set_xkeymap clean_exit 0 else break; fi done done } ################################################################# # Main program case $1 in -h|--help) usage ;; "") menu_kmap ;; *) MAPNAME=$1 if [ -f /usr/share/kbd/keymaps/i386//qwerty/$MAPNAME.map.gz ] || \ [ -f /usr/share/kbd/keymaps/i386/dvorak/$MAPNAME.map.gz ] || \ [ -f /usr/share/kbd/keymaps/i386/azerty/$MAPNAME.map.gz ]; then infobox "Setting up keymap $MAPNAME" "KEYMAP" set_keymap set_xkeymap sleep 2 else menu_kmap fi ;; esac clean_exit 0