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:

1
2
3
4
5
6
7
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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#!/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}"

Record a GIF