from screengrab to gif on linux

prep

figure out capture coordinates, this Python script might help

step 1: grab screen

ffmpeg -video_size 550x50 -framerate 25 -f x11grab -i :0.0+40,180 output.mp4

step 2: get frames

ffmpeg -i output.mp4 -r 25 ./imgs/frames_%04d.png

step 3: glue yourself a gif

convert -loop 0 imgs/*.png -delay 1 -layers Optimize out.gif

details

man ffmpeg  
man convert