Skip to content

Instantly share code, notes, and snippets.

@skateman
Last active December 13, 2017 13:43
Show Gist options
  • Save skateman/de4ac914776a5cb767319cf6f98c119e to your computer and use it in GitHub Desktop.
Save skateman/de4ac914776a5cb767319cf6f98c119e to your computer and use it in GitHub Desktop.
#!/bin/sh
# gifcast - easily create gif screencasts from a selected area
#
# The first run lets you select a rectangle and starts recording while the second run stops the recording.
# Tested on Fedora 24 with GNOME
# Dependencies: xrectsel, byzanz, convert (ImageMagick)
FILE="/run/user/${UID}/$(basename $0).pid"
if [ -f $FILE ]; then
PID=$(cat $FILE)
DEST="$(cat /proc/${PID}/cmdline | xargs -0 -n1 echo | tail -n1 )"
kill $PID
rm -rf $FILE
sleep 1
convert "${DEST}" -loop 0 "${DEST}"
exit
fi
AREA=$(xrectsel "--x=%x --y=%y --width=%w --height=%h")
DEST="$(xdg-user-dir PICTURES)/Screencast from $(date "+%F %H-%M-%S").gif"
byzanz-record $AREA --duration=600 --cursor "${DEST}" &
CAST=$!
echo $CAST > $FILE
trap "kill ${CAST}" 2
wait $CAST
convert "${DEST}" -loop 0 "${DEST}"
rm -f $FILE
@romanblanco
Copy link

romanblanco commented Sep 9, 2016

Fedora packages:

sudo dnf copr enable stbenjam/xrectsel
sudo dnf install xrectsel byzanz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment