Last active
October 18, 2018 00:00
-
-
Save davidofwatkins/467c8089f7880f3e6fe1dc76b0952628 to your computer and use it in GitHub Desktop.
A utility to record your Android screen via ADB
This file contains 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
if [[ ! $(which adb) ]]; then | |
echo "adb not found." | |
exit 1 | |
fi | |
if [[ ! $(adb devices | grep "\tdevice") ]]; then | |
echo "No devices found." | |
exit 1 | |
fi | |
name="screen-recording-$(date '+%Y-%m-%d-%H:%M:%S').mp4" | |
path="/sdcard/screen-recordings/$name" | |
# turn on 'show touches' debug setting | |
adb shell content insert --uri content://settings/system --bind name:s:show_touches --bind value:i:1 | |
printf "\nScreen recording. Press ctrl+c to stop.\n\n" | |
adb shell mkdir -p /sdcard/screen-recordings/ | |
adb shell screenrecord $path | |
# turn 'show touches' off | |
adb shell content insert --uri content://settings/system --bind name:s:show_touches --bind value:i:0 | |
# pull the video off the device | |
adb pull $path . >/dev/null | |
adb shell rm $path | |
echo "Screen recording created at: $name" |
This file contains 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
if [[ ! $(which adb) ]]; then | |
echo "adb not found." | |
exit 1 | |
fi | |
if [[ ! $(adb devices | grep "\tdevice") ]]; then | |
echo "No devices found." | |
exit 1 | |
fi | |
name="screenshot-$(date '+%Y-%m-%d-%H:%M:%S').png" | |
path="/sdcard/screenshots/$name" | |
adb shell mkdir -p /sdcard/screenshots/ | |
adb shell screencap -p $path | |
adb pull $path . >/dev/null | |
adb shell rm $path | |
echo "Screenshot created at: $name" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment