Record a gif with Linux

I found a cool tool called Peek to record a GIF with linux. Unfortunately it does not work well with i3.

So I ended up using byzanz-record instead. My only issue with byzanz is that it requires you to pass x and y coordinates when you want to record a selection of your screen and usually I do not like to count pixels before every recording…

Luckily someone wrote xrectsel, a simple tool to get the geometry of a selected screen region. By combining xrectsel and byzanz it is possible to record a nice GIF with i3 and probably all other window managers:

byzanz-record                                        \
  --cursor                                           \
  --verbose                                          \
  --delay=2                                          \
  --duration=10                                      \
  $(xrectsel "--x=%x --y=%y --width=%w --height=%h") \
  /tmp/recording.gif

To make my life easier I put it in a small shell script called gif.sh:

#!/usr/bin/env sh

[ $# -lt 2 ] && \
  echo 'You have to pass a duration in seconds and a filename: "gif.sh 10 /tmp/record.gif"' && \
  exit 1

byzanz-record                                        \
  --cursor                                           \
  --verbose                                          \
  --delay=2                                          \
  --duration=${1}                                    \
  $(xrectsel "--x=%x --y=%y --width=%w --height=%h") \
  "${2}"

Posted

in

by

Tags: