Last active
August 24, 2016 22:39
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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