Last active
April 11, 2018 12:31
-
-
Save LongboatAline/56e06f30dcb515fdd11f4d38bae1574e to your computer and use it in GitHub Desktop.
Shell script to take (and file) a screenshot from an Android device 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
#!/bin/bash | |
# Installation: configure target directory, and make sure it exists | |
targetdir=/export/Android/Screenshots | |
prefix="android" | |
device=$(adb devices |awk 'NR == 2 {print $1}') | |
prefix=$device | |
############################################# | |
# Formatting: Field Separator, Date format | |
datefmt="+%Y-%m-%d_%H%M" | |
############################################# | |
yesterday=`TZ=CET+24 /bin/date '+%b %e'` | |
now=`/bin/date ${datefmt}` | |
utc=`TZ=UTC /bin/date ${datefmt}` | |
############################################# | |
targetfile=${prefix}-${now} | |
cd ${targetdir} | |
adb shell screencap -p /sdcard/${targetfile}.png && adb pull /sdcard/${targetfile}.png && adb shell rm /sdcard/${targetfile}.png | |
echo Screenshot saved to ${targetdir}/${targetfile}.png | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment