#!/bin/sh if [ "x$1" == x ] ; then direction=normal else direction=$1 fi case $direction in [Cc][Ww]) direction=`xrandr --verbose|awk '/connected/ {print $5}'` case $direction in normal) direction=left; ;; left) direction=inverted; ;; inverted) direction=right; ;; right) direction=normal; ;; ;; [Cc][Cc][Ww]) direction=`xrandr --verbose|awk '/connected/ {print $5}'` case $direction in normal) direction=right; ;; left) direction=normal; ;; inverted) direction=left; ;; right) direction=inverted; ;; ;; esac case $direction in [Nn]ormal) xmodmap -e "keycode 114 = Right" -e "keycode 111 = Up" -e "keycode 113 = Left" -e "keycode 116 = Down"; ;; [Ll]eft) xmodmap -e "keycode 114 = Down" -e "keycode 111 = Right" -e "keycode 113 = Up" -e "keycode 116 = Left"; ;; [Ii]nverted) xmodmap -e "keycode 114 = Left" -e "keycode 111 = Down" -e "keycode 113 = Right" -e "keycode 116 = Up"; ;; [Rr]ight) xmodmap -e "keycode 114 = Up" -e "keycode 111 = Left" -e "keycode 113 = Down" -e "keycode 116 = Right"; ;; *) echo "Usage: $0 [ cw | ccw | normal | inverted | left | right ]"; exit 1; ;; esac xrandr -o $direction