Created
March 6, 2021 15:13
-
-
Save GoldsteinE/a12dc99e686ca5f085b3b23eb41d3e30 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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