summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@no-log.org>2017-05-21 13:04:09 (GMT)
committerWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2017-05-23 21:14:23 (GMT)
commitbb468524fa7cb9a378f824cf975de1d8aa35098f (patch)
treeef78f020eb8982e5370d388669ff17030b5e4096
parentafe0b27f7284f42ac761f8971aee0df5e9dfd782 (diff)
downloaduser-scripts-bb468524fa7cb9a378f824cf975de1d8aa35098f.zip
user-scripts-bb468524fa7cb9a378f824cf975de1d8aa35098f.tar.gz
user-scripts-bb468524fa7cb9a378f824cf975de1d8aa35098f.tar.bz2
screencap: Add naive SSH backend implementation.
This implementation is not efficent as each command will spawn a new ssh command, which has considerable overhead and latency. Example usage: ./screencap.sh -h root@192.168.43.1 -f OUTPUT.PNG Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@no-log.org>
-rwxr-xr-xscreencap/screencap.sh29
1 files changed, 27 insertions, 2 deletions
diff --git a/screencap/screencap.sh b/screencap/screencap.sh
index 53284b3..7ed7d8c 100755
--- a/screencap/screencap.sh
+++ b/screencap/screencap.sh
@@ -18,13 +18,25 @@
set -e
FFMEG="ffmpeg"
-ADB="adb"
+ADB=""
FB_PATH="/dev/graphics/fb0"
+SSH_HOST=""
TMP_FB="fb_raw"
TMP_FB_RS="fb_raw_rs"
RECOVERY=false
+ssh_wrapper()
+{
+ if [ "$1" = "shell" ] ; then
+ shift 1
+ ssh "${SSH_HOST}" "su -c \"$@\""
+ elif [ "$1" = "pull" ] ; then
+ shift 1
+ scp ${SSH_HOST}:$@
+ fi
+}
+
print_usage () {
echo
echo "Usage: $0 [OPTIONS] -f OUTPUT.PNG"
@@ -33,6 +45,7 @@ print_usage () {
echo "Options:"
echo "-r, --recovery Device is booted in recovery mode"
echo "-s, --screen-size Specify screen size (mandatory in recovery mode)"
+ echo "-h, --ssh-host Connect to the given host through SSH"
echo
}
@@ -66,7 +79,8 @@ take_screenshot () {
PIX_FMT="rgb565"
fi
- $ADB pull $FB_PATH $TMP_FB
+ $ADB shell "cat $FB_PATH > /data/local/tmp/$TMP_FB"
+ $ADB pull /data/local/tmp/$TMP_FB $TMP_FB
dd bs=$BS count=$SCREEN_SIZE_Y if=$TMP_FB of=$TMP_FB_RS
$FFMEG -vcodec rawvideo -f rawvideo -pix_fmt $PIX_FMT -s $SCREEN_SIZE \
@@ -91,6 +105,11 @@ do
SCREEN_SIZE="$2"
shift 2
;;
+ -h|--ssh-host)
+ SSH_HOST="$2"
+ shift 2
+ ;;
+
"")
break
;;
@@ -102,6 +121,12 @@ do
esac
done
+if [ -z "${SSH_HOST}" ] ; then
+ ADB="adb"
+else
+ ADB="ssh_wrapper"
+fi
+
if [ "$OUTFILE" = "" ]; then
echo "No output file specified"
print_usage