Right Orientation (rotate-right.sh)

#!/bin/sh

# This script is for X sessions. I don't know how this would
# work in wayland.

orientation="$(xrandr -q | grep -v dis | grep connected | awk '{print $5}' | sed 's:(::')"
displayName="$(xrandr -q | grep -v dis | grep connected | awk '{print $1}')"
matrix="0 1 0 -1 0 1 0 0 1"

if [ "${orientation}" != "right" ] ; then
	xrandr --output "${displayName}" --rotate right
	xinput set-prop "IPTS Touch" --type=float \
		"Coordinate Transformation Matrix" ${matrix}
	xinput set-prop "IPTS Stylus Pen (0)" --type=float \
		"Coordinate Transformation Matrix" ${matrix}
	xinput set-prop "IPTS Stylus Eraser (0)" --type=float \
		"Coordinate Transformation Matrix" ${matrix}
	xinput set-prop "Microsoft Surface Keyboard Mouse" --type=float \
		"Coordinate Transformation Matrix" ${matrix}
	xinput set-prop "Microsoft Surface Keyboard Touchpad" --type=float \
		"Coordinate Transformation Matrix" ${matrix}
fi
