Created
February 12, 2013 05:13
-
-
Save zirneklitis/4760391 to your computer and use it in GitHub Desktop.
Graphical interface (zenity based shell script) for command line utility byzanz-record
This file contains 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/bash | |
# AUTHOR: (c) [email protected] 2013.02.07. | |
# NAME: byzanz window recorder 0.0.3 | |
# DESCRIPTION: A script to record GIF, OGV, FLV and WebM screencasts. | |
# LICENSE: GNU GPL v3 (http://www.gnu.org/licenses/gpl.html) | |
# DEPENDENCIES: byzanz, zenity | |
# Based on http://askubuntu.com/questions/107726/how-to-create-animated-gif-images-of-a-screencast | |
# Delay before starting | |
DELAY=6 | |
# Recording duration | |
DURATION=600 | |
# Icon of message windows | |
ICON=/usr/share/icons/gnome/16x16/actions/gtk-media-record.png | |
# Sound notification to let one know when recording is about to start and ends | |
beep() { | |
paplay /usr/share/sounds/freedesktop/stereo/complete.oga | |
} | |
# Encapsulated byzanz-record command (with sound signals and delay) | |
komanda (){ | |
sleep $DELAY | |
beep | |
byzanz-record --verbose --cursor --delay=0 --duration=$DURATION --x=$X --y=$Y --width=$W --height=$H "$FAILS" | |
beep | |
exit 0 | |
} | |
if [ $(command -v byzanz-record) ]; then | |
echo "byzanz-record exists" | |
else | |
echo "Error: „byzanz-record” NOT FOUND in \$PATH." | |
exit 1 | |
fi | |
if [ $(command -v zenity) ]; then | |
echo "zenity exists" | |
else | |
echo "Error: „zenity” NOT FOUND in \$PATH." | |
exit 1 | |
fi | |
FAILS=$(zenity \ | |
--title="Choose the file and directory for output (gif/flv/byzanz/ogg/ogv/webm)" \ | |
--window-icon=$ICON \ | |
--file-selection \ | |
--confirm-overwrite \ | |
--save) | |
if [ $FAILS ]; then | |
echo The output will be written to $FAILS | |
rm $FAILS | |
else | |
echo "Error: No file selected for output." | |
exit 1 | |
fi | |
DURATION=$(zenity \ | |
--title="Chose the window to be recorded" \ | |
--window-icon=$ICON \ | |
--entry \ | |
--text="The window will be recorded with „byzanz”.\nAfter closing this window, You have to click\non a window to be recorded. Afterwards the record\nwill start in $DELAY seconds.\n\nThe record's duration in seconds:" \ | |
--ok-label="Record a window" \ | |
--cancel-label="Do nothing" \ | |
--entry-text=$DURATION ) | |
if [ $DURATION ]; then | |
if [ $DURATION -le "3" ]; then | |
echo "Error: Record duration is set too small." | |
exit 1 | |
else | |
TIMEOUT=$(($DELAY + $DURATION + $DURATION * 3)) | |
LOGS=$(xwininfo -frame) | |
read X < <(awk -F: '/Absolute upper-left X/{print $2}' <<< "$LOGS") | |
read Y < <(awk -F: '/Absolute upper-left Y/{print $2}' <<< "$LOGS") | |
read W < <(awk -F: '/Width/{print $2}' <<< "$LOGS") | |
read H < <(awk -F: '/Height/{print $2}' <<< "$LOGS") | |
komanda & | |
zenity \ | |
--window-icon=$ICON \ | |
--text="The duration of the record is $DURATION seconds.\nBy closing this window the recording will be cancelled.\nIn this case ogg/ogv/webm will be truncated." \ | |
--timeout=$TIMEOUT \ | |
--progress \ | |
--percentage=100 | |
killall -e -w byzanz-record | |
exit 13 | |
fi | |
else | |
echo "Error: Program aborted." | |
exit 1 | |
fi |
This file contains 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
[Desktop Entry] | |
Version=1.0 | |
Encoding=UTF-8 | |
Type=Application | |
Name=Byzanz window recorder | |
Name[lv]=Loga kopētājs | |
Comment=A script to record screencasts inside the selected window | |
Comment[lv]=Ieraksta notiekošo uzrādītajā logā ar byzanz-record | |
Categories=Graphics;Utility; | |
Exec=byzanz-record-window | |
Icon=gtk-media-record | |
Terminal=false | |
StartupNotify=false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment