Skip to content

Instantly share code, notes, and snippets.

@apg
Last active August 24, 2016 22:39
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 apg/5a6722c462dbed9a68e2a53c6625bc89 to your computer and use it in GitHub Desktop.
Save apg/5a6722c462dbed9a68e2a53c6625bc89 to your computer and use it in GitHub Desktop.
fork of Kgif, to make it more generalized. Repo coming https://github.com/luminousmen/Kgif
#!/bin/sh
# capturing delay
SCROT_DELAY=0.5
# delay in gif
GIF_DELAY=10
# clean tmp directory
ctrlc() {
echo "\nStop capturing"
echo "Converting to gif..."
convert -quiet -delay $GIF_DELAY -loop 0 *.png ../terminal.gif
cd ..
if [ "$noclean" = false ] ; then
echo "Cleaning..."
clean
fi
echo "Done!"
exit 2
}
clean() {
rm -rf $NOW
}
capturing() {
echo "Capturing..."
cd ./$NOW
last=$(xprop -root _NET_ACTIVE_WINDOW)
active=$last
while test "$last" = "$active";
do
last=$active
scrot -u -d $SCROT_DELAY
active=$(xprop -root _NET_ACTIVE_WINDOW)
done
ctrlc
}
# main()
trap "ctrlc" INT TERM
NOW=$(date +"%m-%d-%Y_%H:%M:%S")
if [ ! -d ./$NOW ]; then
mkdir ./$NOW
fi
# if no delay passing
if test -z "$delay" ; then
delay=1
fi
if test -z "$noclean" ; then
noclean=false
fi
# wait for a while
sleep $delay
capturing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment