From 103a6612f3987807b1abb99621d79fb6d59ff5cb Mon Sep 17 00:00:00 2001 From: Stacy Harper Date: Thu, 26 Aug 2021 20:39:31 +0200 Subject: [PATCH] Fix autorotation script Signed-off-by: Stacy Harper Signed-off-by: Maarten van Gompel --- scripts/core/sxmo_dmenu.sh | 6 +++--- scripts/core/sxmo_rotate.sh | 32 +++++++++++++++++++++++--------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/scripts/core/sxmo_dmenu.sh b/scripts/core/sxmo_dmenu.sh index d457e6f..21cf3db 100755 --- a/scripts/core/sxmo_dmenu.sh +++ b/scripts/core/sxmo_dmenu.sh @@ -28,13 +28,13 @@ esac > /dev/null case "$(sxmo_wm.sh)" in sway) - exec bemenu --scrollbar autohide -n -w -c -l "$(sxmo_rotate.sh isrotated && printf 5 || printf 15)" "$@" + exec bemenu --scrollbar autohide -n -w -c -l "$(sxmo_rotate.sh isrotated > /dev/null && printf 5 || printf 15)" "$@" ;; xorg|dwm) if sxmo_keyboard.sh isopen; then - exec dmenu -c -l "$(sxmo_rotate.sh isrotated && printf 2 || printf 5)" "$@" + exec dmenu -c -l "$(sxmo_rotate.sh isrotated > /dev/null && printf 2 || printf 5)" "$@" else - exec dmenu -c -l "$(sxmo_rotate.sh isrotated && printf 7 || printf 23)" "$@" + exec dmenu -c -l "$(sxmo_rotate.sh isrotated > /dev/null && printf 7 || printf 23)" "$@" fi ;; ssh) diff --git a/scripts/core/sxmo_rotate.sh b/scripts/core/sxmo_rotate.sh index b7e086a..a237ca1 100755 --- a/scripts/core/sxmo_rotate.sh +++ b/scripts/core/sxmo_rotate.sh @@ -16,21 +16,35 @@ swaytransforms() { } xorgisrotated() { - case "$(xrandr | grep primary | cut -d' ' -f 5)" in - *right*|*left*) return 0;; - *) return 1;; - esac + rotation="$( + xrandr | grep primary | cut -d' ' -f 5 | sed s/\(// + )" + if [ "$rotation" = "normal" ]; then + return 1; + fi + printf %s "$rotation" + return 0; } swayisrotated() { - swaytransforms | grep DSI-1 | grep -q 0 + rotation="$( + swaytransforms \ + | grep DSI-1 \ + | cut -d" " -f2 \ + | sed -e s/90/right/ -e s/270/left/ -e s/180/reverse/ + )" + if [ "$rotation" = "normal" ]; then + return 1; + fi + printf %s "$rotation" + return 0; } xorgrotnormal() { sxmo_keyboard.sh close xrandr -o normal applyptrmatrix 0 0 0 0 0 0 0 0 0 - sxmo_hooks.sh lisgdstart + sxmo_hooks.sh lisgdstart & exit 0 } @@ -50,7 +64,7 @@ xorgrotright() { swayrotright() { swaymsg -- output DSI-1 transform 90 - sxmo_hooks.sh lisgdstart + sxmo_hooks.sh lisgdstart & exit 0 } @@ -58,13 +72,13 @@ xorgrotleft() { sxmo_keyboard.sh close xrandr -o left applyptrmatrix 0 -1 1 1 0 0 0 0 1 - sxmo_hooks.sh lisgdstart + sxmo_hooks.sh lisgdstart & exit 0 } swayrotleft() { swaymsg -- output DSI-1 transform 270 - sxmo_hooks.sh lisgdstart + sxmo_hooks.sh lisgdstart & exit 0 }