screenshot 817 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/sh
  2. DATE=$(date +'%Y/%m/%d')
  3. COUNT=1
  4. FILENAME=~/Pictures/Screenshots/${DATE}/${COUNT}.png
  5. mkdir -p "$(dirname "${FILENAME}")"
  6. until [[ ! -e $FILENAME ]]
  7. do
  8. FILENAME=~/Pictures/Screenshots/${DATE}/${COUNT}.png
  9. COUNT=$(( COUNT + 1 ))
  10. done
  11. TYPE=root
  12. while getopts rwsf:? opt
  13. do
  14. case "$opt" in
  15. r)
  16. TYPE=root
  17. ;;
  18. w)
  19. TYPE=window
  20. ;;
  21. s)
  22. TYPE=select
  23. ;;
  24. f)
  25. FILENAME="$OPTARG"
  26. ;;
  27. [?])
  28. echo "screenshot [ -? ] [ -r | -w | -s ] [ -f filename.png ]" >&2
  29. exit 1
  30. ;;
  31. esac
  32. done
  33. case $TYPE in
  34. root)
  35. scrot "${FILENAME}"
  36. ;;
  37. window)
  38. scrot -b -u "${FILENAME}"
  39. ;;
  40. select)
  41. scrot -s "${FILENAME}"
  42. ;;
  43. esac