diff --git a/thinkpad-yoga-rotate/rotate-screen.sh b/thinkpad-yoga-rotate/rotate-screen.sh index 3ba2cb6..e56cc19 100755 --- a/thinkpad-yoga-rotate/rotate-screen.sh +++ b/thinkpad-yoga-rotate/rotate-screen.sh @@ -6,13 +6,14 @@ user="$(who -u | grep -F '(:0)' | head -n 1 | awk '{print $1}')" # A convenience function to run a command in the X server context -with_display() { DISPLAY=:0.0 su -c "$(printf "%q " "$@")" "$user"; } +with_display() { DISPLAY=:0 su -c "$(printf "%q " "$@")" "$user"; } # As the same ACPI event is currently emitted for both going in and out # of the tablet mode, we need to toggle the orientation # Figure out the current rotation: -current=`with_display xrandr -q --verbose | grep eDP1 | cut -d " " -f5` +current=`with_display xrandr -q --verbose | grep eDP1 | grep -o -E 'left|normal' | head -1` + # Set the next orientation case $current in