tRecord a gif from a specific window - scripts - various script and utils
(HTM) git clone git://z3bra.org/scripts
(DIR) Log
(DIR) Files
(DIR) Refs
---
(DIR) commit eba7c1f8d43686d0f944ad665d20b98ac9f364c1
(DIR) parent e4d2736ef249b55bab8dc8ae7210661bf190597e
(HTM) Author: z3bra <willy@mailoo.org>
Date: Mon, 3 Nov 2014 20:43:16 +0100
Record a gif from a specific window
Diffstat:
A xgif | 45 +++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/xgif b/xgif
t@@ -0,0 +1,45 @@
+#!/bin/sh
+#
+# z3bra - (c) wtfpl 2014
+# record a gif from a specific window until ^D
+
+usage () {
+ cat <<EOF
+usage: `basename $0` [-h] <file>
+ -h : print this help
+
+environment:
+ BORDERS : set the window border size (default: 5)
+EOF
+}
+
+case $1 in
+ -h) usage && exit 0;;
+ *) test $# -lt 1 && usage && exit 1
+esac
+
+# the size of your window manager borders, to include them in the gif
+BORDERS=${BORDER:-5}
+
+# let the user grab a window
+geom=$(xwininfo|grep -E "Wid|Hei|Abs"|sed 's/.*:\s*//g'|tr '\n' :|sed 's/:$//')
+
+# extract window size/position
+x=$(echo $geom|cut -d: -f1)
+y=$(echo $geom|cut -d: -f2)
+w=$(echo $geom|cut -d: -f3)
+h=$(echo $geom|cut -d: -f4)
+
+# add the borders to the width/heigh
+w=$(( $w + 2 * $BORDERS))
+h=$(( $h + 2 * $BORDERS))
+
+# this hackery serves the purpose of recording until the user press ^D
+fifo="/tmp/xgif-$$.fifo"
+test -p $fifo || mkfifo $fifo
+
+byzanz-record -x $x -y $y -w $w -h $h -e "cat $fifo" $1 &
+
+# will hold the fifo openned until ^D is pressed
+cat > $fifo
+rm $fifo