#!/usr/bin/env bash # STD_COPYRIGHT# # $Id: wacom-rot90 16263 2009-01-21 16:44:17Z jeremy $ # # lhm 7/12/09 current rotation changes # #LOCKFILE="/opt/emperor/var/run/wacom-rot90.lock" LOCKFILE="/tmp/wacom-rot90.lock" T_x="0" T_y="0" B_x="24576" B_y="18432" # film installation error deltas, dots at 2500dpi D_x="0" D_y="0" function SetWacomOrientationNormal() { xsetwacom set stylus TopX $(($T_x+$D_x)) xsetwacom set stylus TopY $(($T_y+$D_y)) xsetwacom set stylus BottomX $(($B_x+$D_x)) xsetwacom set stylus BottomY $(($B_y+$D_y)) } function SetWacomOrientationRotInv() { xsetwacom set stylus TopX $(($T_x-$D_x)) xsetwacom set stylus TopY $(($T_y-$D_y)) xsetwacom set stylus BottomX $(($B_x-$D_x)) xsetwacom set stylus BottomY $(($B_y-$D_y)) } function SetWacomOrientationRotRight() { xsetwacom set stylus TopX $(($T_y-$D_y)) xsetwacom set stylus TopY $(($T_x-$D_x)) xsetwacom set stylus BottomX $(($B_y-$D_y)) xsetwacom set stylus BottomY $(($B_x-$D_x)) } function SetWacomOrientationRotLeft() { xsetwacom set stylus TopX $(($T_y+$D_y)) xsetwacom set stylus TopY $(($T_x+$D_x)) xsetwacom set stylus BottomX $(($B_y+$D_y)) xsetwacom set stylus BottomY $(($B_x+$D_x)) } function go_right() { xrandr -o right xsetwacom set stylus rotate CW SetWacomOrientationRotRight } function go_left() { xrandr -o left xsetwacom set stylus rotate CCW SetWacomOrientationRotLeft } function go_normal() { xrandr -o normal xsetwacom set stylus rotate NONE SetWacomOrientationNormal } function go_inverted() { xrandr -o inverted xsetwacom set stylus rotate HALF SetWacomOrientationRotInv } if [ -f "${LOCKFILE}" ]; then exit fi touch "${LOCKFILE}" #CURRENT_ROTATION=$(xrandr | grep '^Current rotation - ' | sed 's/^Current rotation - //g') CURRENT_ROTATION=$(xrandr | grep 'LVDS' | cut -d " " -f 4 | sed 's/^(normal/normal/g') echo $CURRENT_ROTATION if [ -n "${1}" ]; then case "${1}" in *normal ) go_normal ;; inverted) go_inverted ;; right) go_right ;; left) go_left ;; toggle) if [ "${CURRENT_ROTATION}" = "inverted" ]; then go_normal else go_inverted fi ;; *) echo "usage: wacom-rot90 {normal | inverted | right | left}" ;; esac else case "${CURRENT_ROTATION}" in *normal) go_right ;; right) go_inverted ;; inverted) go_left ;; left) go_normal ;; *) true ;; esac fi rm -f "${LOCKFILE}"