X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=usr_bin%2Fcaps-ctrl;h=824ddd1a1fde0968a6c3d28c9e247848af269120;hb=5b0c6b200fe0a76b7a78c984733defdb3120ea6a;hp=b0d8f649778b89f1d792ba986f560e9392ce7241;hpb=9fef74081f53d30174118872324fa62d4a8145b5;p=grml-scripts.git diff --git a/usr_bin/caps-ctrl b/usr_bin/caps-ctrl index b0d8f64..824ddd1 100755 --- a/usr_bin/caps-ctrl +++ b/usr_bin/caps-ctrl @@ -6,18 +6,24 @@ # 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 || exit 1 +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 [[ $UID != 0 ]] ; then # test if user root did invoke this command + if [ $(id -u) != 0 ] ; then # test if user root did invoke this command eerror "As of Linux 2.6.15 you need root permissions for changing" - eerror "the keyboard on console using loadkeys for security reasons." + eerror "the keyboard on console using loadkeys for security reasons." eerror "Run this program with root permissions. Exiting." ; eend 1 exit 1 fi @@ -25,8 +31,8 @@ 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 '` + keycode 58 = $(repeat 15 echo -n 'Control ') + keycode 29 = $(repeat 7 echo -n 'Caps_Lock ') EOT eend $? @@ -34,8 +40,8 @@ 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 'Caps_Lock '` - keycode 29 = `repeat 7 echo -n 'Control '` + keycode 58 = $(repeat 15 echo -n 'Caps_Lock ') + keycode 29 = $(repeat 7 echo -n 'Control ') EOT eend $? )