Skip to content

Instantly share code, notes, and snippets.

@vibragiel
Created September 9, 2015 13:26
Show Gist options
  • Save vibragiel/6c27bfd70615faaf72d2 to your computer and use it in GitHub Desktop.
Save vibragiel/6c27bfd70615faaf72d2 to your computer and use it in GitHub Desktop.
Script to grab a screenshot, put it in a Dropbox directory and copy its public link into the clipboard. Modified from: http://askubuntu.com/a/201018
#!/bin/bash
# AUTHOR: (c) Rob W 2012, modified by MHC (http://askubuntu.com/users/81372/mhc), modified by Gabi (http://gabi.is) to use xrectsel and Dropbox
# 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 beep)
# Time and date
TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
# Delay before starting
DELAY=3
# Standard screencast folder
FOLDER="$HOME/Dropbox/Public/screencasts"
# Default recording duration
DEFDUR=10
# 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 &
}
# 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
# xrectsel from https://github.com/lolilolicon/xrectsel
DIMENSION_ARGUMENTS=$(xrectsel "--x=%x --y=%y --width=%w --height=%h") || exit -1
# 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 $DIMENSION_ARGUMENTS "$FOLDER/GIFrecord-$TIME.gif"
beep
# Notify the user of end of recording.
notify-send "GIFRecorder" "Screencast saved to $FOLDER/GIFrecord_$TIME.gif"
# Copy Dropbox public URL into the clipboard
dropbox puburl "$FOLDER/GIFrecord-$TIME.gif" | xclip -selection c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment