#!/bin/sh # rotate all of the attached displays XRANDR_OUTPUT=$(xrandr -q) OUTPUTS=$(echo "$XRANDR_OUTPUT" |awk '/ connected /{print $1}') set -x for output in $OUTPUTS; do NEW_ORIENTATION="left" # figure out current orientation ORIENTATION=$(echo "$XRANDR_OUTPUT"|grep "^$output "|awk '{print $4}') if [ "x$ORIENTATION" = "xleft" ]; then NEW_ORIENTATION="inverted"; elif [ "x$ORIENTATION" = "xinverted" ]; then NEW_ORIENTATION="right"; elif [ "x$ORIENTATION" = "xright" ]; then NEW_ORIENTATION="normal"; else NEW_ORIENTATION="left"; fi; xrandr --output $OUTPUTS --rotate $NEW_ORIENTATION; done;