Advertisement
j0h

simpleScreenRecorderLinux.sh

j0h
May 8th, 2023
3,302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.91 KB | None | 0 0
  1. #!/bin/bash
  2. #this program captures a screenshot every second untill ctrl+C is pressed.
  3. #On exit, convert images to a gif.
  4.  
  5. #This program requires gnome-screenshot, coreutils, and imagemagic
  6. #Should you want to quit, without the exit process, press ctrl+Z
  7.  
  8. CDIR=$PWD
  9. #make a temporary location to store files.
  10. export TMPDIR=`mktemp -d  $PWD/screenCap.XXXXXX`
  11. # trap ctrl-c and call ctrl_c()
  12. trap ctrl_c INT
  13. FName=$(date +%Y-%m-%d%H-%M-%S).gif
  14. function ctrl_c() {
  15.         echo "** Trapped CTRL-C Exit process initializing"
  16.         convert -delay 40 -loop 0 *.png $FName
  17.         sleep 5   #convert is funny.
  18.         cp $FName $CDIR
  19.         echo -e  $FName " complete. Exiting "
  20.         rm -rf $TMPDIR
  21.         exit
  22. }
  23.  
  24. cd  $TMPDIR
  25. N=1
  26. while true
  27.      do
  28.        gnome-screenshot  -f $(date +%Y-%m-%d%H-%M-%S).png
  29.         echo -e "you have captured" $N "frames\n"
  30.         N=$((N + 1))
  31.         sleep 1
  32. done
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement