Created
April 22, 2015 14:19
-
-
Save singpolyma/77004677bffbe1cbfeb2 to your computer and use it in GitHub Desktop.
Revisions
-
singpolyma created this gist
Apr 22, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ #!/bin/sh set -e x="$(cat /sys/bus/iio/devices/iio:device0/in_accel_x_raw)" y="$(cat /sys/bus/iio/devices/iio:device0/in_accel_y_raw)" abs_x="$x" [ "$x" -lt 0 ] && abs_x=$(( $x * -1 )) abs_y="$y" [ "$y" -lt 0 ] && abs_y=$(( $y * -1 )) if [ "$abs_x" -lt 70 ] && [ "$abs_y" -lt 70 ]; then # No change (lying flat) exit fi current="$(xrandr -q --verbose | grep '^LVDS1 ' | cut -d' ' -f5)" if [ "$abs_y" -gt "$abs_x" ]; then if [ "$y" -lt 0 ]; then [ "$current" != "inverted" ] && xrandr -o inverted else [ "$current" != "normal" ] && xrandr -o normal fi else if [ "$x" -lt 0 ]; then [ "$current" != "left" ] && xrandr -o left else [ "$current" != "right" ] && xrandr -o right fi fi