Taking a screenshot on a Tolino

When an Android device is connected via USB to the computer, you can take a screenshot via adb:

$ adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > file.png

On a Tolino e-book reader, this unfortunately added some textual information before the actual PNG image data:

vinfo.xoffset = 0
vinfo.yoffset = 2144
vinfo.xres = 1448
vinfo.yres = 1072
vinfo.xres_virtual = 1472
vinfo.yres_virtual = 3456
.PNG...

The solution is to use grep in binary mode to remove those:

~/bin/android-screenshot
#!/bin/sh
adb\
    shell screencap -p\
    | grep -a -v '^vinfo\.' \
    | perl -pe 's/\x0D\x0A/\x0A/g' \
    > "screenshot-`date --rfc-3339=seconds`.png"

Written by Christian Weiske.

Comments? Please send an e-mail.