Created
June 12, 2025 03:57
-
-
Save MeexReay/5f5661b47fbcc6708b07c8cc1c62ffd2 to your computer and use it in GitHub Desktop.
simple script for auto-rotate screen for postmarketos
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 characters
#!/bin/bash | |
ROTATE_OLD=0 | |
rotate_screen () { | |
if [ "$1" == "$ROTATE_OLD" ]; then | |
return | |
fi | |
waydroid shell settings put system user_rotation $1 | |
echo $1 | |
ROTATE_OLD=$1 | |
} | |
monitor-sensor --accel 2>&1 | while read -r msg; do | |
if [[ $msg == "Accelerometer orientation changed:"* ]]; then | |
case ${msg#"Accelerometer orientation changed: "} in | |
left-up) rotate_screen 3 ;; | |
right-up) rotate_screen 1 ;; | |
bottom-up) rotate_screen 2 ;; | |
normal) rotate_screen 0 ;; | |
esac | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment