4
# Screen capture of Mir devices
7
# Copyright (C) 2013 Canonical
9
# Authors: Jean-Baptiste Lallement <jean-baptiste.lallement@canonical.com>
11
# This program is free software; you can redistribute it and/or modify it #
12
# under the terms of the GNU General Public License as published by the Free #
13
# Software Foundation; version 3.
15
# This program is distributed in the hope that it will be useful, but WITHOUT
16
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
17
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
20
# You should have received a copy of the GNU General Public License along with
21
# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
22
# Street, Fifth Floor, Boston, MA 02110-1301 USA
25
# - detect that it is running Mir and fallback to screencap if it is SF
29
PICDIR=$(mktemp -d /tmp/$(basename $0).XXXXXX)
32
#CONVERTOPTS="-alpha off -resize 50%"
33
CONVERTOPTS="-alpha off"
34
SUPPORTED="maguro mako manta grouper"
35
FILENAME=$HOME"/Pictures/device-`date +%Y-%m-%d-%H%M%S`.png"
37
SVRPATH="~/public_html/phablet"
39
PUBPATH="~alan/phablet"
40
WEBADDR=$PROTO$SVR/$PUBPATH/`basename $FILENAME`
44
# Cleanup temporary files
46
[ -d "$PICDIR" ] && rm -Rf "$PICDIR"
48
trap cleanup EXIT INT QUIT ABRT PIPE TERM
52
# Print usage and exit
55
Usage: $(basename $0) [OPTIONS...]
56
Dump /dev/$FBDEV from a touch device and write it to file
61
-s SERIAL Serial number of the device
67
check_prerequisites() {
68
# Check list of required packages
72
if ! type $cmd >/dev/null 2>&1; then
74
pkg="$(dpkg -S usr/bin/$cmd|cut -d: -f1)"
75
echo "E: Command '$cmd' not found in path. Please install package '$pkg'."
79
if [ $okay -ne 1 ]; then
80
echo "E: pre-requisites are not met. Exiting!"
87
device=$(adb $ADBOPTS shell getprop ro.cm.device)
88
echo "$device"|tr -d '\r'
93
size=$(adb $ADBOPTS shell head -1 /sys/devices/virtual/graphics/$FBDEV/modes| cut -d: -f2|cut -d 'p' -f1)
95
# Fallback to hardcoded values
96
#if ! echo "$size"|grep -qE '^\[0-9\]+x\[0-9\]+$' >/dev/null 2>&1; then
97
if ! echo "$size"|grep -qE '^[0-9]+x[0-9]+$' >/dev/null 2>&1; then
98
device="$(get_device)"
114
echo "E: Device '$device' is not supported. Supported devives are: $SUPPORTED"
122
LONGOPTS="help,debug,serial:"
124
TEMP=$(getopt -o $SHORTOPTS --long $LONGOPTS -- "$@")
135
ADBOPTS="$ADBOPTS -s $2"
147
# Set resolution and depth for device
150
if [ -z "$size" ]; then
151
device="$(get_device)"
152
echo "E: Device '$device' is not supported. Supported devives are: $SUPPORTED"
155
CONVERTOPTS="$CONVERTOPTS -depth $depth -size $size"
157
echo "I: Dumping $FBDEV ..."
158
adb $ADBOPTS shell "kill -SIGSTOP \$(pidof unity8)"
159
adb $ADBOPTS pull /dev/$FBDEV ${PICDIR}/fb
160
adb $ADBOPTS shell "kill -SIGCONT \$(pidof unity8)"
162
convert $CONVERTOPTS rgba:${PICDIR}/fb[0] $DST
164
xdg-open $DST 2>&1 > /dev/null &
165
scp $DST $SVR:$SVRPATH