Skip to content

Instantly share code, notes, and snippets.

@ljubisa987
Forked from alekswn/adb_rotate.sh
Created October 30, 2016 22:22
Show Gist options
  • Save ljubisa987/d7d8d9dfb6c6fc8c9c35e93e17f953af to your computer and use it in GitHub Desktop.
Save ljubisa987/d7d8d9dfb6c6fc8c9c35e93e17f953af to your computer and use it in GitHub Desktop.
Android: screen rotation from ADB
#!/bin/sh
if [ -z $1 ]
then
echo "Usage: $0 { p | l | a }. p - portrait, l - landscape, a - auto"
elif [[ $1 == a* ]]
then
echo "Turning on automatic rotation"
adb shell content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:1
else
echo "Turning off automatic rotation"
adb shell content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:0
if [[ $1 == p* ]]
then
echo "Rotating screen portrait"
adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:0
elif [[ $1 == l* ]]
then
echo "Rotating screen landscape"
adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:1
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment