diff --git a/bin/scrcap b/bin/scrcap index 2ae935c4..d1478b3c 100755 --- a/bin/scrcap +++ b/bin/scrcap @@ -4,6 +4,8 @@ # 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=${1:-0.6} -us >"$tmp"; then @@ -12,5 +14,3 @@ if maim --delay=${1:-0.6} -us >"$tmp"; then else notify-send -u low "Aborted screenshot" fi - -rm -f "$tmp"