diff --git a/scripts/core/sxmo_appmenu.sh b/scripts/core/sxmo_appmenu.sh index 89f2293..936cc91 100755 --- a/scripts/core/sxmo_appmenu.sh +++ b/scripts/core/sxmo_appmenu.sh @@ -50,7 +50,7 @@ programchoicesinit() { Modem Log ^ 0 ^ sxmo_modemlog.sh Flash $(cat /sys/class/leds/white:flash/brightness | grep -E '^0$' > /dev/null && echo -n "Off → On" || echo -n "On → Off") ^ 1 ^ sxmo_flashtoggle.sh Bar Toggle ^ 1 ^ key Alt+b - Rotate ^ 1 ^ rotate + Rotate ^ 1 ^ sxmo_rotate.sh Wifi ^ 0 ^ st -e "nmtui" Audio Out ^ 0 ^ sxmo_audiooutmenu.sh Upgrade Pkgs ^ 0 ^ st -e sxmo_upgrade.sh @@ -161,10 +161,6 @@ getprogchoices() { PROGCHOICES="$(echo "$CHOICES" | xargs -0 echo | sed '/^[[:space:]]*$/d' | awk '{$1=$1};1')" } -rotate() { - xrandr | grep primary | cut -d' ' -f 5 | grep right && xrandr -o normal || xrandr -o right -} - key() { xdotool windowactivate "$WIN" xdotool key --clearmodifiers "$1" diff --git a/scripts/core/sxmo_rotate.sh b/scripts/core/sxmo_rotate.sh new file mode 100755 index 0000000..8426a50 --- /dev/null +++ b/scripts/core/sxmo_rotate.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env sh + +applyptrmatrix() { + PTRID="$( + xinput | grep -iE 'touchscreen.+pointer' | grep -oE 'id=[0-9]+' | cut -d= -f2 + )" + xinput set-prop "$PTRID" --type=float --type=float "Coordinate Transformation Matrix" "$@" +} + +isrotated() { + xrandr | grep primary | cut -d' ' -f 5 | grep right && return 0 + return 1 +} + +rotnormal() { + xrandr -o normal + applyptrmatrix 0 0 0 0 0 0 0 0 0 + exit 0 +} + +rotright() { + xrandr -o right + applyptrmatrix 0 1 0 -1 0 1 0 0 1 + exit 0 +} + +rotate() { + isrotated && rotnormal || rotright +} + +rotate