Skip to content

Instantly share code, notes, and snippets.

@mwcz
Created September 27, 2016 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwcz/e92f4bfdf7260557c0b196b745070d8c to your computer and use it in GitHub Desktop.
Save mwcz/e92f4bfdf7260557c0b196b745070d8c to your computer and use it in GitHub Desktop.
gif command for recording animated gifs in Linux
#!/bin/bash
# USAGE: gif SECONDS FILENAME
# example: gif 4 out.gif
# then drag a box :D
# Delay before starting
DELAY=0
# Duration and output file
if [ $# -gt 0 ]; then
D="--duration=$@"
else
FILE="/tmp/$(date +%s).gif"
echo Default recording duration ${DELAY}s to $FILE
D="--duration=10 $FILE"
fi
# xrectsel from https://github.com/lolilolicon/xrectsel
ARGUMENTS=$(xrectsel "--x=%x --y=%y --width=%w --height=%h") || exit -1
echo Delaying $DELAY seconds. After that, byzanz will start
for (( i=$DELAY; i>0; --i )) ; do
echo $i
sleep 1
done
byzanz-record -c --verbose --delay=0 ${ARGUMENTS} $D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment