Skip to content

Instantly share code, notes, and snippets.

@97-109-107
Created March 6, 2014 23:36
Show Gist options
  • Save 97-109-107/9402049 to your computer and use it in GitHub Desktop.
Save 97-109-107/9402049 to your computer and use it in GitHub Desktop.
#!/bin/bash
# This is a minimal frontend to byzanz-record that provides a gui for
# selecting a region or window and length of a gif screen-cast.
# Depends on xrectsel (part of ffcast), byzanz-record, zenity
# Most code stolen from Rob W and MHC http://askubuntu.com/a/201018
DELAY=5
DEFDUR=10
TIME=$(date +"%Y-%m-%d_%H%M%S")
USERDUR=$(gdialog --title "Duration?" --inputbox "Please enter the screencast duration in seconds" 200 100 2>&1)
if [ $USERDUR -gt 0 ]; then
D=$USERDUR
else
D=$DEFDUR
fi
MODE=$(zenity --list --text="Choose action" --hide-header --column a Window Area)
if [ $MODE == "Window|Window" ]; then
XWININFO=$(xwininfo);
X=$(echo $XWININFO | grep -Po '(?<=Absolute upper-left X: )[0-9]*');
Y=$(echo $XWININFO | grep -Po '(?<=Absolute upper-left Y: )[0-9]*');
W=$(echo $XWININFO | grep -Po '(?<=Width: )[0-9]*');
H=$(echo $XWININFO | grep -Po '(?<=Height: )[0-9]*');
notify-send "gifcastgui" "Recording will start in $DELAY seconds." -t 5000
sleep $DELAY
byzanz-record --verbose -c --delay=0 --x=$X --y=$Y --width=$W --height=$H --duration=$D "/tmp/gifcast_$TIME.gif"
notify-send "gifcastgui" "Recording done" -t 5000
else
AREA=$(xrectsel "--x=%x --y=%y --width=%w --height=%h") || exit -1
notify-send "gifcastgui" "Recording will start in $DELAY seconds." -t 5000
sleep $DELAY
byzanz-record --verbose -c --delay=0 $AREA --duration=$D "/tmp/gifcast_$TIME.gif"
notify-send "gifcastgui" "Recording done" -t 5000
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment