window-manager/scripts/rotate.sh

37 lines
No EOL
1.3 KiB
Bash
Executable file

#!/bin/bash
ORIENTATION="$(head -n1 <(monitor-sensor --accel | grep --line-buffered -Eo "normal|left-up|bottom-up|right-up"))"
hyprctl activewindow|grep Waydroid >> /dev/null
if [ $? -eq 0 ]; then
"$(dirname "$(realpath "$0")")/waydroid-root.sh" "rotate-$ORIENTATION"
ORIENTATION="normal"
fi
if [[ "$ORIENTATION" == "normal" ]]; then
hyprctl keyword monitor eDP-1,preferred,0x0,1,transform,0
hyprctl keyword input:tablet:transform 0
hyprctl keyword input:touchdevice:transform 0
elif [[ "$ORIENTATION" == "left-up" ]]; then
hyprctl keyword monitor eDP-1,preferred,0x0,1,transform,1
hyprctl keyword input:tablet:transform 1
hyprctl keyword input:touchdevice:transform 1
elif [[ "$ORIENTATION" == "bottom-up" ]]; then
hyprctl keyword monitor eDP-1,preferred,0x0,1,transform,2
hyprctl keyword input:tablet:transform 2
hyprctl keyword input:touchdevice:transform 2
elif [[ "$ORIENTATION" == "right-up" ]]; then
hyprctl keyword monitor eDP-1,preferred,0x0,1,transform,3
hyprctl keyword input:tablet:transform 3
hyprctl keyword input:touchdevice:transform 3
else
hyprctl notify 3 1000 000 "Unknown orientation: $ORIENTATION. Resetting to normal."
hyprctl keyword monitor eDP-1,preferred,0x0,1,transform,0
hyprctl keyword input:tablet:transform 0
hyprctl keyword input:touchdevice:transform 0
exit 1;
fi
killall monitor-sensor
exit 0;