dmenu-scrot.sh 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env bash
  2. set -euo pipefail # bash strict mode
  3. #changelog
  4. #v0.3
  5. #added 1. Notifications 2.unique names for each type (for quick launch) 3.better photo editor (pinta) 4.dmenu title
  6. #v0.4
  7. #1.Added variable for notification timeouts. 2. Show link in notification
  8. IMG_PATH=/home/dt/scrot/
  9. UL=fb
  10. EDIT=gimp
  11. TIME=3000 #Miliseconds notification should remain visible
  12. prog="
  13. ---Local screenshots (saved at IMG_PATH)---
  14. 1.quick_fullscreen
  15. 2.delayed_fullscreen
  16. 3.section
  17. 4.edit_fullscreen
  18. ---Upload to remote service (images will be deleted)---
  19. a.upload_fullscreen
  20. u.upload_delayed_fullscreen
  21. e.edit_upload_fullscreen
  22. s.upload_section
  23. p.edit_upload_section
  24. "
  25. cmd=$(dmenu -l 20 -nf '#999' -nb '#292d3e' -sf '#ooo' -sb '#0077bb' -p 'Choose Screenshot Type' <<< "$prog")
  26. cd $IMG_PATH
  27. case ${cmd%% *} in
  28. 1.quick_fullscreen) scrot -d 1 '%Y-%m-%d-@%H-%M-%S-scrot.png' && notify-send -u low -t $TIME 'Scrot' 'Fullscreen taken and saved' ;;
  29. 2.delayed_fullscreen) scrot -d 4 '%Y-%m-%d-@%H-%M-%S-scrot.png' && notify-send -u low -t $TIME 'Scrot' 'Fullscreen Screenshot saved' ;;
  30. 3.section) scrot -s '%Y-%m-%d-@%H-%M-%S-scrot.png' && notify-send -u low -t $TIME 'Scrot' 'Screenshot of section saved' ;;
  31. 4.edit_fullscreen) scrot -d 1 '%Y-%m-%d-@%H-%M-%S-scrot.png' -e "$EDIT \$f" && notify-send -u low -t $TIME 'Scrot' 'Screenshot edited and saved' ;;
  32. a.upload_fullscreen) scrot -d 1 '%Y-%m-%d-@%H-%M-%S-scrot.png' -e "$UL \$f" && (xclip -o;echo) | xclip -selection clipboard && notify-send -u low -t $TIME "Scrot" "Screenshot Uploaded (powered by fb) - $(xclip -o;echo)" ;;
  33. u.upload_delayed_fullscreen) scrot -d 4 '%Y-%m-%d-@%H-%M-%S-scrot.png' -e "$UL \$f" && (xclip -o;echo) | xclip -selection clipboard && notify-send -u low -t $TIME "Scrot" "Screenshot Uploaded (powered by fb) - $(xclip -o)" ;;
  34. e.edit_upload_fullscreen) scrot -d 4 '%Y-%m-%d-@%H-%M-%S-scrot.png' -e "$EDIT \$f && $UL \$f && rm -f \$f" && notify-send -u low -t $TIME "Scrot" "Screenshot Uploaded (powered by fb) - $(xclip -o)" ;;
  35. s.upload_section) scrot -s '%Y-%m-%d-@%H-%M-%S-scrot.png' -e "$UL \$f" && (xclip -o;echo) | xclip -selection clipboard && notify-send -u low -t $TIME "Scrot" "Screenshot Uploaded (powered by fb - $(xclip -o)";;
  36. p.edit_upload_section) scrot -s '%Y-%m-%d-@%H-%M-%S-scrot.png' -e "$EDIT \$f && $UL \$f && rm -f \$f" && (xclip -o;echo) | xclip -selection clipboard && notify-send -u low -t $TIME "Scrot" "Screenshot Uploaded (powered by FB) - $(xclip -o)" ;;
  37. *) exec "'${cmd}'" ;;
  38. esac