2020-01-12 15:18:09 -08:00
|
|
|
#!/usr/bin/env cached-nix-shell
|
|
|
|
#! nix-shell -i bash -p maim slop
|
2019-08-06 10:56:54 -07:00
|
|
|
|
|
|
|
# A script that takes a screenshot (prompts you for what region/window to
|
|
|
|
# capture) and stores it in the clipboard.
|
|
|
|
|
|
|
|
tmp=$(mktemp)
|
2020-01-03 19:56:12 -08:00
|
|
|
cleanup() { rm -f "$tmp"; }
|
|
|
|
trap cleanup EXIT
|
2019-08-06 10:56:54 -07:00
|
|
|
|
|
|
|
# Delay for long enough that we can refocus the targeted window
|
2020-01-12 15:18:09 -08:00
|
|
|
if maim --delay=${2:-1} -us >"$tmp"; then
|
2019-08-06 10:56:54 -07:00
|
|
|
xclip -selection clipboard -t image/png "$tmp" &&
|
2020-02-08 20:26:11 -08:00
|
|
|
notify-send "Screenshot saved" "Copied image to clipboard"
|
2019-08-06 10:56:54 -07:00
|
|
|
else
|
|
|
|
notify-send -u low "Aborted screenshot"
|
|
|
|
fi
|