#!/bin/sh
#                       /usr/local/bin/rotate
# https://crystalfaeries.net/posix/bin/rotate
# celeste:crystalfaery ROTATE 2016-10-20 17:10:35+00:00
# Linux Journal 182 of 2009 June Page 36 Kyle Rankin

export ORIENTATION=`cat /tmp/.orientation`

if [ $ORIENTATION -eq "90" ]; then
	xrandr --auto
	xrandr --output LVDS --rotate inverted
	echo  180  > /tmp/.orientation
	echo "180" |  osd_cat --shadow=2 --align=center		\
	--pos=bottom --color=green --delay=2			\
	--font=lucidasanstypewriter-bold-24 --offset 40 &
elif [ $ORIENTATION -eq "180" ]; then
	xrandr --auto
	xrandr --output LVDS --rotate left
	echo  270  > /tmp/.orientation
	echo "270" |  osd_cat --shadow=2 --align=center		\
	--pos=bottom --color=green --delay=2			\
	--font=lucidasanstypewriter-bold-24 --offset 40 &
elif [ $ORIENTATION -eq "270" ]; then
	xrandr --auto
	xrandr --output LVDS --rotate normal
	echo  000  > /tmp/.orientation
	echo "000" |  osd_cat --shadow=2 --align=center		\
	--pos=bottom --color=green --delay=2			\
	--font=lucidasanstypewriter-bold-24 --offset 40 &
else
	xrandr --auto
	xrandr --output LVDS --rotate right
	echo  090  > /tmp/.orientation
	echo "090" |  osd_cat --shadow=2 --align=center		\
	--pos=bottom --color=green --delay=2			\
	--font=lucidasanstypewriter-bold-24 --offset 40 &
fi


syntax highlighted by Code2HTML, v. 0.9.1