i3-snapshot 655 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/sh
  2. DATE=(`date +%F`)
  3. COUNT=0
  4. FILENAME=~/Pictures/snapshot-${DATE}-${COUNT}.png
  5. until [[ ! -e $FILENAME ]]
  6. do
  7. FILENAME=~/Pictures/snapshot-${DATE}-${COUNT}.png
  8. COUNT=`expr ${COUNT} + 1`
  9. done
  10. TYPE=root
  11. while getopts rwf:? opt
  12. do
  13. case "$opt" in
  14. r)
  15. TYPE=root
  16. ;;
  17. w)
  18. TYPE=window
  19. ;;
  20. f)
  21. FILENAME="$OPTARG"
  22. ;;
  23. [?])
  24. echo "i3-snapshot [ -? ] [ -r | -w ] [ -f filename.png ]" >&2
  25. exit 1
  26. ;;
  27. esac
  28. done
  29. if [[ $TYPE == "root" ]] ; then
  30. import -window root ${FILENAME}
  31. else
  32. import ${FILENAME}
  33. fi