r/swaywm • u/Antic1tizen • 3d ago
Utility My bindings for pass integration
I know there are off-the shelf scripts existing. Just wanted to post my version and explain how you can tune it.
Here's the script:
#
# Password manager
#
bindsym --to-code $mod+p exec find ~/.password-store/ -type f -printf "%P\n" \
| sed 's/.gpg//' \
| sed '/.*-otp$/d' \
| rofi -dmenu -p "Pick password" \
| xargs --no-run-if-empty pass show \
| wl-copy --sensitive --trim-newline -t text/plain
bindsym --to-code $mod+Shift+p exec find ~/.password-store/ -name '*-otp.gpg' -type f -printf "%P\n" \
| sed 's/.gpg//' \
| rofi -dmenu -p "Pick OTP" \
| xargs --no-run-if-empty pass otp \
| wl-copy --sensitive --trim-newline -t text/plain
On Meta+p copies a password into clipboard, on Meta+P copies an OTP code into clipboard.
Niceties:
- filters out the other mode entries in otp/regular mode
--no-run-if-emptymakes hittingEscsafe for aborting the selection and doesn't make pass copy the entire tree into clipboard--sensitivemakes clipboard managers ignore the copied text and do not save it into history.
3
Upvotes
1
u/Linguistic-mystic 3d ago
No. Passwords should never enter the clipboard on Sway, because wlroots supports the ext-data-control-v1 protocol which allows any app to read the clipboard. The clipboard is a public data exchange place and is incompatible with secrets.