Advertisement
Guest User

GIFRecord 0.1

a guest
Feb 23rd, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.76 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # AUTHOR:   (c) Rob W 2012, modified by MHC (http://askubuntu.com/users/81372/mhc)
  4. # NAME:     GIFRecord 0.1
  5. # DESCRIPTION:  A script to record GIF screencasts.
  6. # LICENSE:  GNU GPL v3 (http://www.gnu.org/licenses/gpl.html)
  7. # 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)
  8.  
  9. # Time and date
  10. TIME=$(date +"%Y-%m-%d_%H%M%S")
  11.  
  12. # Delay before starting
  13. DELAY=2
  14.  
  15. # Standard screencast folder
  16. FOLDER="$HOME/Pictures"
  17.  
  18. # Default recording duration
  19. DEFDUR=10
  20.  
  21. # Sound notification to let one know when recording is about to start (and ends)
  22. beep() {
  23.       paplay /usr/share/sounds/freedesktop/stereo/message-new-instant.oga &
  24. }
  25.  
  26. # Custom recording duration as set by user
  27. USERDUR=$(gdialog --title "Duration?" --inputbox "Please enter the screencast duration in seconds" 200 100 2>&1)
  28.  
  29. # Duration and output file
  30. if [ $USERDUR -gt 0 ]; then
  31.     D=$USERDUR
  32.     else
  33.         D=$DEFDUR
  34.     fi
  35.  
  36. # Window geometry
  37.     XWININFO=$(xwininfo)
  38.     read X < <(awk -F: '/Absolute upper-left X/{print $2}' <<< "$XWININFO")
  39.     read Y < <(awk -F: '/Absolute upper-left Y/{print $2}' <<< "$XWININFO")
  40.     read W < <(awk -F: '/Width/{print $2}' <<< "$XWININFO")
  41.     read H < <(awk -F: '/Height/{print $2}' <<< "$XWININFO")
  42.  
  43. # Notify the user of recording time and delay
  44.     notify-send "GIFRecorder" "Recording duration set to $D seconds. Recording will start in $DELAY seconds."
  45.  
  46. #Actual recording
  47.     sleep $DELAY
  48.     beep
  49.     byzanz-record -c --verbose --delay=0 --duration=$D --x=$X --y=$Y --width=$W --height=$H "$FOLDER/GIFrecord_$TIME.gif"
  50.     beep
  51.  
  52. # Notify the user of end of recording.
  53.     notify-send "GIFRecorder" "Screencast saved to $FOLDER/GIFrecord_$TIME.gif"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement