/usr/bin/olpc-rotate is in olpc-kbdshim 27-1build1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | #!/bin/sh
# Rotates the XO screen 90 degrees on every invocation
# fifo where commands to rotate the touchpad may be written
CMD_FIFO=/var/run/olpc-kbdshim_command
new_screen=""
case $1 in
"") # usual case -- rotate to next in counter-clockwise sequence
;;
left|right|normal|inverted) # force a specific rotation
new_screen=$1
new_tpad=$1
;;
-e)
# -e and -n enable/disable axis reflection for the
# touchpad. this allows "normal" use of the touchpad
# when you're in ebook mode and crack open the laptop
# slightly to use the touchpad. otherwise the both
# directions are reversed.
echo Z >$CMD_FIFO
exit 0
;;
-n)
echo z >$CMD_FIFO
exit 0
;;
-r) # resets touchpad rotation to unrotated, used when X is restarted
echo n >$CMD_FIFO
exit 0
;;
*)
echo "usage: $0 [-e|-n|-r|left|right|normal|inverted]" >&2
exit 1;;
esac
get_x_credentials()
{
# fetch the local X server's XAUTHORITY variable
eval "$( xargs -n 1 -0 < /proc/$(pidof X)/environ | grep '^XAUTHORITY=')"
export XAUTHORITY
export DISPLAY=:0
}
test "$XAUTHORITY" || get_x_credentials
# get current screen orientation
if ! xrandrout=$(xrandr --query)
then
echo xrandr query failed >&2
exit 1
fi
# pick up the output device and its current rotation from the same line.
# the line looks like:
# LCD connected 900x1200+0+0 right (normal left inverted right x axis y axis) 0mm x 0mm
# the first word ("LCD") is the output device, "right" is the current
# rotation, but in the "normal" case, the word "right" will be missing
# entirely.
set -- $(echo "$xrandrout" |
sed -n 's/^\([a-zA-Z0-9]\+\) *connected .*[0-9] \([a-z]*\) *(.*/\1 \2/p')
output="$1"
now="$2"
if [ ! "$new_screen" ]
then
# some xrandr/X11-driver implementations will rotate the screen
# the wrong way:
# - xorg-x11-drv-geode library in F9-based OLPC releases
# - SWRandR in F11-based OLPC releases
#
# in those cases, we allow olpc-utils to set a flag so we can
# reverse what we tell xrandr to do. note that in this case
# xrandr will be reporting the wrong thing too in $now.
if [ -e /var/run/olpc-rotate-reverse ]
then # assume xrand reports and performs mirrored rotation.
case $now in
left) new_screen=normal; new_tpad=normal;;
inverted) new_screen=left; new_tpad=right;;
right) new_screen=inverted; new_tpad=inverted;;
""|normal) new_screen=right; new_tpad=left;;
*) new_screen=normal; new_tpad=normal;;
esac
else
# we always want to cycle the screen counterclockwise
case $now in
left) new_tpad=inverted;;
inverted) new_tpad=right;;
right) new_tpad=normal;;
""|normal) new_tpad=left;;
*) new_tpad=normal;;
esac
new_screen="$new_tpad"
fi
fi
# set the new rotation, and inform kbdshim to rotate the touchpad.
xrandr --output $output --rotate $new_screen && \
test -e $CMD_FIFO && echo $new_tpad >$CMD_FIFO
|