You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xgif 1020B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/sh
  2. #
  3. # z3bra - (c) wtfpl 2014
  4. # record a gif from a specific window until ^D
  5. usage () {
  6. cat <<EOF
  7. usage: `basename $0` [-h] <file>
  8. -h : print this help
  9. environment:
  10. BORDERS : set the window border size (default: 5)
  11. EOF
  12. }
  13. case $1 in
  14. -h) usage && exit 0;;
  15. *) test $# -lt 1 && usage && exit 1
  16. esac
  17. # the size of your window manager borders, to include them in the gif
  18. BORDERS=${BORDER:-5}
  19. # let the user grab a window
  20. geom=$(xwininfo|grep -E "Wid|Hei|Abs"|sed 's/.*:\s*//g'|tr '\n' :|sed 's/:$//')
  21. # extract window size/position
  22. x=$(echo $geom|cut -d: -f1)
  23. y=$(echo $geom|cut -d: -f2)
  24. w=$(echo $geom|cut -d: -f3)
  25. h=$(echo $geom|cut -d: -f4)
  26. # add the borders to the width/heigh
  27. w=$(( $w + 2 * $BORDERS))
  28. h=$(( $h + 2 * $BORDERS))
  29. # this hackery serves the purpose of recording until the user press ^D
  30. fifo="/tmp/xgif-$$.fifo"
  31. test -p $fifo || mkfifo $fifo
  32. byzanz-record -x $x -y $y -w $w -h $h -e "cat $fifo" $1 &
  33. # will hold the fifo openned until ^D is pressed
  34. cat > $fifo
  35. rm $fifo