X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=usr_bin%2Fcaps-ctrl;h=b4bd3cc3de5a3c1a05ae1ed34ce67eb6a1652693;hb=ec7a53a2517d85db80eaba4e0c77210391cbd12c;hp=8096e42b4279a502a1afa543682aa516a2676b06;hpb=1f0b02fbbe5adaea1054672d7cf9d6a37ff9178e;p=grml-scripts-core.git diff --git a/usr_bin/caps-ctrl b/usr_bin/caps-ctrl index 8096e42..b4bd3cc 100755 --- a/usr_bin/caps-ctrl +++ b/usr_bin/caps-ctrl @@ -6,13 +6,19 @@ # License: This file is licensed under the GPL v2. ################################################################################ -if . /etc/grml/script-functions ; then - check4progs xmodmap loadkeys dumpkeys || exit 1 +if [[ -f /etc/grml/script-functions ]] ; then + source /etc/grml/script-functions \ + && check4progs xmodmap loadkeys dumpkeys +fi +if [[ -f /etc/grml/lsb-functions ]] ; then + source /etc/grml/lsb-functions +else + einfo() { echo "$*" ; } + eerror() { echo "$*" ; } + eend() { echo "$*" ; } fi -. /etc/grml/lsb-functions || ( alias einfo=echo ; alias eerror=echo; alias eend=echo ) emulate zsh -autoload -U colors ; colors if [[ -z $DISPLAY ]] ; then # test if X is not running when calling us if [ $(id -u) != 0 ] ; then # test if user root did invoke this command @@ -25,18 +31,18 @@ if [[ -z $DISPLAY ]] ; then # test if X is not running when calling us ( einfo "caps-ctrl - switching caps lock and control key." loadkeys <<- EOT - keycode 58 = `repeat 15 echo -n 'Control '` - keycode 29 = `repeat 7 echo -n 'Caps_Lock '` - EOT + keycode 58 = $(repeat 15 echo -n 'Control ') + keycode 29 = $(repeat 7 echo -n 'Caps_Lock ') + EOT eend $? ) || ( einfo "caps-ctrl - switching caps lock and control key." loadkeys <<- EOT - keycode 58 = `repeat 15 echo -n 'Caps_Lock '` - keycode 29 = `repeat 7 echo -n 'Control '` - EOT + keycode 58 = $(repeat 15 echo -n 'Caps_Lock ') + keycode 29 = $(repeat 7 echo -n 'Control ') + EOT eend $? ) @@ -48,7 +54,7 @@ else # running under X xmodmap -pke | grep 'Caps_Lock' > /dev/null || ( xmodmap - <<- EOT keycode 66 = Caps_Lock - EOT + EOT ) xmodmap - <<- EOT @@ -64,7 +70,7 @@ else # running under X add lock = Caps_Lock add Control = Control_L !add Control = Control_R - EOT + EOT eend $? ) fi # end of test if X or console is used