Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@GoldsteinE
Created March 6, 2021 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GoldsteinE/a12dc99e686ca5f085b3b23eb41d3e30 to your computer and use it in GitHub Desktop.
Save GoldsteinE/a12dc99e686ca5f085b3b23eb41d3e30 to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
bounds="$(slop -b 0 -lc 0.1,0.6,0.8,0.4 -qf '%x,%y,%w,%h' 2>/dev/null)"
[ "$?" -eq "0" ] || exit 0
filename="$(date +'%Y-%m-%dT%H.%M.%S')_$(pwgen 5 1).png"
screenshot_dir="${SCREENSHOT_DIR:-$HOME/Pictures/Screenshots}"
mkdir -p "$screenshot_dir"
scrot -a "$bounds" "$screenshot_dir/$filename"
mime_type="$(file -b --mime-type "$screenshot_dir/$filename")"
xclip -selection clipboard -t "$mime_type" "$screenshot_dir/$filename"
wh="$(echo "$bounds" | tr , x | cut -dx -f3-4)"
notify-send "Copied $wh image to clipboard"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment