mkscreenshot.sh 1014 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/sh
  2. sspath="$HOME/pictures/screenshots"
  3. tmpss="/tmp/tmp_mkscreenshot.png"
  4. choice=$(printf "Select\nFull Screen\nActive Window" | dmenu -i)
  5. save_screenshot () {
  6. # copy screenshot as image to clipboard (pasting in Telegram, ...)
  7. xclip -t image/png -selection clipboard -i < "$tmpss"
  8. name=$(echo '' | dmenu -p "Enter Name:")
  9. if [ "$name" = "" ]; then
  10. echo '[-] Aborting...'
  11. exit 0
  12. fi
  13. mv "$tmpss" "$sspath/$name.png"
  14. notify-send "screenshot has been saved in ~/pictures/screenshots"
  15. }
  16. # Choice between Full Screen, Active Window and Selection
  17. if [ "$choice" = "Select" ]
  18. then
  19. notify-send "select an area for the screenshot"
  20. scrot -s $tmpss
  21. if [ $? -eq 0 ]; then
  22. save_screenshot
  23. fi
  24. elif [ "$choice" = "Full Screen" ]
  25. then
  26. sleep 0.2s
  27. scrot $tmpss
  28. if [ $? -eq 0 ]; then
  29. save_screenshot
  30. fi
  31. elif [ "$choice" = "Active Window" ]
  32. then
  33. scrot -u $tmpss
  34. if [ $? -eq 0 ]; then
  35. save_screenshot
  36. fi
  37. fi