Skip to content

Instantly share code, notes, and snippets.

@Nilzor
Last active August 11, 2017 06:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nilzor/32c44b0a59d5db9bbc8c7e162ad4d53d to your computer and use it in GitHub Desktop.
Save Nilzor/32c44b0a59d5db9bbc8c7e162ad4d53d to your computer and use it in GitHub Desktop.
bash.rc for Android screenshot and recording
And-Screenshot() {
# Todo: Add demo mode: https://android.googlesource.com/platform/frameworks/base/+/master/packages/SystemUI/docs/demo_mode.md
if [ "$1" = "" ] ; then echo "Specify output file name"
else
adb shell screencap -p /sdcard/screen.png
adb pull /sdcard/screen.png
adb shell rm /sdcard/screen.png
PCT=$2
if [ "$PCT" = "" ]; then PCT=33%; fi
convert screen.png -resize $PCT $1
# Line below requires python and the script image2clip provided below.
# Copies the image to clipboard
image2clip $1
rm screen.png
fi
}
And-Record() {
if [ "$1" -eq "" ] ; then echo "Specify output file name"
else
tmpFile=/sdcard/temp-video.mp4
adb shell screenrecord $tmpFile
sleep 1
adb pull $tmpFile $1
adb shell rm $tmpFile
fi
}
#! /usr/bin/python
# This script copies the contents of an image file to clipboard
import pygtk
pygtk.require('2.0')
import gtk
import os
import sys
def copy_image(f):
assert os.path.exists(f), "file does not exist"
image = gtk.gdk.pixbuf_new_from_file(f)
clipboard = gtk.clipboard_get()
clipboard.set_image(image)
clipboard.store()
copy_image(sys.argv[1]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment