Skip to main content

max / alloy

1.0 KB · 28 lines History Blame Raw
1 #!/bin/sh
2 # alloy-clipstore — store a clipboard selection, unless it is a secret.
3 #
4 # What the sway config's two `wl-paste --watch` lines call instead of
5 # `cliphist store` directly. The read half is still alloy-clipmenu and the
6 # store is still cliphist's; this only decides whether an item reaches it.
7 #
8 # The rule is one line: if alloy-secret-copy left its sentinel, this selection
9 # is a password on its way to a paste and is not history. See that script for
10 # why a sentinel rather than the `x-kde-passwordManagerHint` MIME convention,
11 # and for the failure direction it is built around. GO alloy problem e7a9e38c.
12 #
13 # Consuming stdin on the skip path is deliberate. `wl-paste --watch` writes the
14 # selection to this process; exiting without reading it leaves the writer with
15 # a closed pipe and a SIGPIPE on the next selection, which is a broken watcher
16 # rather than a skipped item.
17
18 set -eu
19
20 sentinel="${XDG_RUNTIME_DIR:-/tmp}/alloy-secret-clipboard"
21
22 if [ -e "$sentinel" ]; then
23 cat >/dev/null
24 exit 0
25 fi
26
27 exec cliphist store
28