-
-
Save scalopus/c6d0ce26ee1515e4f03f to your computer and use it in GitHub Desktop.
Record Screen as Git Image
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/bash | |
# AUTHOR: (c) Rob W 2012, modified by MHC (http://askubuntu.com/users/81372/mhc) | |
# NAME: GIFRecord 0.1 | |
# DESCRIPTION: A script to record GIF screencasts. | |
# LICENSE: GNU GPL v3 (http://www.gnu.org/licenses/gpl.html) | |
# DEPENDENCIES: byzanz,gdialog,notify-send (install via sudo add-apt-repository ppa:fossfreedom/byzanz; sudo apt-get update && sudo apt-get install byzanz gdialog notify-osd) | |
# Time and date | |
TIME=$(date +"%Y-%m-%d_%H%M%S") | |
# Delay before starting | |
DELAY=3 | |
# Standard screencast folder | |
FOLDER="$HOME/Dropbox/Screenshots" | |
FILENAME_TEMPLATE=$FOLDER/$TIME-Screencast.gif | |
# Default recording duration | |
DEFDUR=5 | |
# Sound notification to let one know when recording is about to start (and ends) | |
beep() { | |
paplay /usr/share/sounds/freedesktop/stereo/message-new-instant.oga & | |
} | |
window() { | |
echo "Record in Windows Mode" | |
} | |
area() { | |
echo "Record in Area Mode" | |
} | |
# Custom recording duration as set by user | |
USERDUR=$(gdialog --title "Duration?" --inputbox "Please enter the screencast duration in seconds" 200 100 2>&1) | |
# Duration and output file | |
if [ $USERDUR -gt 0 ]; then | |
D=$USERDUR | |
else | |
D=$DEFDUR | |
fi | |
MODE=$(gdialog --title "Capture Mode?" --inputbox "1. Window , 2. Region" 200 100 2>&1) | |
if [ $MODE -eq 1 ]; then | |
# Window geometry | |
XWININFO=$(xwininfo) | |
read X < <(awk -F: '/Absolute upper-left X/{print $2}' <<< "$XWININFO") | |
read Y < <(awk -F: '/Absolute upper-left Y/{print $2}' <<< "$XWININFO") | |
read W < <(awk -F: '/Width/{print $2}' <<< "$XWININFO") | |
read H < <(awk -F: '/Height/{print $2}' <<< "$XWININFO") | |
ARGUMENTS="--x=$X --y=$Y --width=$W --height=$H" | |
window | |
else | |
ARGUMENTS=$(xrectsel "--x=%x --y=%y --width=%w --height=%h") || exit -1 | |
area | |
fi | |
# Notify the user of recording time and delay | |
notify-send "GIFRecorder" "Recording duration set to $D seconds. Recording will start in $DELAY seconds." | |
#Actual recording | |
sleep $DELAY | |
beep | |
byzanz-record -c --verbose --delay=0 --duration=$D ${ARGUMENTS} "$FILENAME_TEMPLATE" | |
beep | |
# Notify the user of end of recording. | |
notify-send "GIFRecorder" "Screencast saved to $FILENAME_TEMPLATE" |
Author
scalopus
commented
Jul 16, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment