Last active
March 2, 2021 20:50
-
-
Save esutton/c71615324e26c2de448e009722dfd85c to your computer and use it in GitHub Desktop.
Capture screenshot from adb connected Android device & save to ~/Desktop
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/sh | |
############################################ | |
# File: adb-cap.sh | |
# ----------------------- | |
# Script to capture screenshot to file from adb connected Android device and save to ~/Desktop. | |
# | |
# Free for any use. | |
# Tested on macOS | |
# Debug on: set -x | |
#set -x | |
fileSaveFolder=~/Desktop | |
fileName=adb-cap-`date +%Y-%m-%d_%H-%M-%S`.png | |
if [ $# -eq 1 ]; then | |
fileName="$1" | |
fi | |
if ! [ ${fileName: -4} == ".png" ]; then | |
fileName=${fileName}.png | |
fi | |
fileNamePath=${fileSaveFolder}/${fileName} | |
echo "adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > ${fileNamePath}" | |
adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > ${fileNamePath} | |
echo Saved to: | |
echo ${fileNamePath} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment