helm/bin/scrcap
Henrik Lissner ef3b5df3cb
Use cached-nix-shell for scr{cap,rec} scripts
Also refactor them
2020-01-12 18:20:28 -05:00

18 lines
489 B
Plaintext
Executable file

#!/usr/bin/env cached-nix-shell
#! nix-shell -i bash -p maim slop
# A script that takes a screenshot (prompts you for what region/window to
# capture) and stores it in the clipboard.
tmp=$(mktemp)
cleanup() { rm -f "$tmp"; }
trap cleanup EXIT
# Delay for long enough that we can refocus the targeted window
if maim --delay=${2:-1} -us >"$tmp"; then
xclip -selection clipboard -t image/png "$tmp" &&
notify-send "Screenshot saved"
else
notify-send -u low "Aborted screenshot"
fi