Skip to main content

max / alloy

789 B · 22 lines History Blame Raw
1 #!/bin/sh
2 # alloy-secret-clear — clear the clipboard and re-enable history.
3 #
4 # The other half of alloy-secret-copy, and what gopass runs through
5 # $GOPASS_CLIPBOARD_CLEAR_CMD when its timeout expires. Clearing the clipboard
6 # is wl-copy's job; removing the sentinel is what lets alloy-clipstore start
7 # recording again.
8 #
9 # Order matters and is the reverse of the copy path. The clipboard is cleared
10 # first and the sentinel removed second, so there is no window in which history
11 # is live and the secret is still on the clipboard.
12 #
13 # Safe to run when nothing is pending: both steps are idempotent, and gopass
14 # calls this on paths where it is not certain a copy happened.
15
16 set -eu
17
18 sentinel="${XDG_RUNTIME_DIR:-/tmp}/alloy-secret-clipboard"
19
20 wl-copy --clear || true
21 rm -f "$sentinel"
22