Skip to content

Instantly share code, notes, and snippets.

@lorenzos
Created July 14, 2015 09:19
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 lorenzos/dd2f792f4eb948a139ee to your computer and use it in GitHub Desktop.
Save lorenzos/dd2f792f4eb948a139ee to your computer and use it in GitHub Desktop.
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