Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Records a portion of your screen to an animated GIF
#!/bin/bash
#
# RECORDS A PORTION OF YOUR SCREEN TO AN ANIMATED GIF
#
# REQUIREMENTS:
# byzanz: Screen recorder, found in repos
# zenity: Dialogs and notifications, found in repos
# xrectsel: Screen portion selector, found at https://github.com/lolilolicon/xrectsel
#
FILENAME=$(zenity --file-selection --save --confirm-overwrite --filename='/tmp/byzanz-record.gif')
if [[ -n "$FILENAME" ]]; then
DELAY=$(zenity --entry --title="Capture delay in seconds:" --text="Capture delay in seconds:" --entry-text="1" --width=260)
DURATION=$(zenity --entry --title="Capture duration in seconds:" --text="Capture duration in seconds:" --entry-text="8" --width=260)
RECT=$(xrectsel | sed -r 's/(.*)x(.*)\+(.*)\+(.*)/-x \3 -y \4 -w \1 -h \2/')
byzanz-record -d $DURATION --delay $DELAY $RECT "$FILENAME"
zenity --notification --title="GIF saved" --text="GIF saved. Click the button to open it" --timeout=4
if [[ "$?" == "0" ]]; then
exo-open "$FILENAME"
fi
exit 0
else
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.