Advertisement
Interknet

Untitled

Mar 8th, 2020
695
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.48 KB | None | 0 0
  1. #!/bin/sh
  2. Notifications=1
  3. ScreenshotSound=1
  4. CopyToClipboard=1
  5. ScreenshotSoundEffect=$HOME/Documents/Scripts/Sounds/ScreenshotSound.mp3
  6. ScreenshotLocation="$HOME/Pictures/Screenshotter"
  7.  
  8. Part1() {
  9. WinName=$(xprop -id $(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2) | grep WM_CLASS | awk '{print $4}' | tr -d '"')
  10. mkdir -p "$ScreenshotLocation/${WinName^}"
  11. Time=$(date '+%Y-%m-%d_%T')
  12. PictureName="$ScreenshotLocation/${WinName^}/$(date '+%Y-%m-%d_%T')_${WinName^}"
  13. }
  14.  
  15. Part2() {
  16. if [ $ScreenshotSound -eq "1" ]; then
  17.     play $ScreenshotSoundEffect
  18. fi
  19. if [ $CopyToClipboard -eq "1" ]; then
  20.     xclip -selection clipboard -t image/png "$PictureName"
  21.     Copied="\nCopied to clipboard!"
  22. fi
  23. if [ $Notifications -eq "1" ]; then
  24.     notify-send --app-name=Screenshotter "Screenshot of ${WinName^} taken!" "Saved to $HOME/Pictures/Screenshotter$Copied"
  25. fi
  26. }
  27.  
  28. case "$1" in
  29.         (-w | --window) ## Takes screenshot of the whole window
  30.         Part1
  31.         scrot -u -q 100 "$PictureName"
  32.         Part2
  33.         exit 1
  34.         ;;
  35.         (-s | --select) ## Select area to take screenshot of
  36.         Part1
  37.         scrot -s -q 100 "$PictureName"
  38.         Part2
  39.         exit 1
  40.         ;;
  41.         (-u | --upload) ## Uploads clipboard image to Imgur, using imgur-screenshot: https://github.com/jomo/imgur-screenshot
  42.         echo "not done"      ## Use after taking a screenshot to upload if you need a link to an image.
  43.         exit 1
  44.         ;;
  45. ("")
  46. echo "Use options; -w for window, -s for select"
  47. exit 2
  48. ;;
  49. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement