scripts

various script and utils
git clone git://z3bra.org/scripts
Log | Files | Refs

commit 3d570a262b644b9aa53c2b113bc3b9a181fd76d6
parent d5aefdb1a7d66e739be41af119de16d063d4b510
Author: z3bra <willy@mailoo.org>
Date:   Thu Oct 23 16:37:02 +0200

Small utility to record a window (uses byzanz)

Diffstat:
xrecord | 48++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+), 0 deletions(-)
diff --git a/xrecord b/xrecord @@ -0,0 +1,48 @@ +#!/bin/bash +# +# record a window as a gif + +# Default duration +DURATION=${1:-16} + +# windows border size +BORDERS=5 + +# dumb user is dumb +usage() { + echo "usage: $(basename $0) [-h] [-d <duration>] <filename>" +} + +while getopts "hd:" opt; do + case $opt in + d) DURATION=$OPTARG ;; + *) usage; exit 1;; + esac +done + +# Let user select a window to extract relevant infos +# Clicking on root window works +geometry=$(xwininfo \ + | grep -E "Width|Height|Absolute upper-left" \ + | cut -d: -f2 \ + | tr '\n' ' ' \ + | sed 's/^\s*//;s/\s*$//;s/\s\+/:/g') + +x=$(echo $geometry | cut -d: -f1) +y=$(echo $geometry | cut -d: -f2) +w=$(echo $geometry | cut -d: -f3) +h=$(echo $geometry | cut -d: -f4) + +shift $(( OPTIND - 1 )) + +# don't forget the filename ! +test -n "$1" && OUTFILE=$1 || { usage; exit 1; } + +# add border size to width/height +w=$(( w + 2 * $BORDERS )) +h=$(( h + 2 * $BORDERS )) + +# actually record... +byzanz-record -x $x -y $y -w $w -h $h -d $DURATION $OUTFILE + +exit 0