i3-snapshot 705 B

123456789101112131415161718192021222324252627282930313233343536373839
  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 rwf:? opt
  13. do
  14. case "$opt" in
  15. r)
  16. TYPE=root
  17. ;;
  18. w)
  19. TYPE=window
  20. ;;
  21. f)
  22. FILENAME="$OPTARG"
  23. ;;
  24. [?])
  25. echo "i3-snapshot [ -? ] [ -r | -w ] [ -f filename.png ]" >&2
  26. exit 1
  27. ;;
  28. esac
  29. done
  30. if [[ $TYPE == "root" ]] ; then
  31. import -window root "${FILENAME}"
  32. else
  33. import "${FILENAME}"
  34. fi