Skip to content

Instantly share code, notes, and snippets.

@MeexReay
Created June 12, 2025 03:57
Show Gist options
  • Save MeexReay/5f5661b47fbcc6708b07c8cc1c62ffd2 to your computer and use it in GitHub Desktop.
Save MeexReay/5f5661b47fbcc6708b07c8cc1c62ffd2 to your computer and use it in GitHub Desktop.
simple script for auto-rotate screen for postmarketos
#!/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