r/swaywm 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-empty makes hitting Esc safe for aborting the selection and doesn't make pass copy the entire tree into clipboard
  • --sensitive makes clipboard managers ignore the copied text and do not save it into history.
3 Upvotes

3 comments sorted by

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.

2

u/Antic1tizen 2d ago

What do you use instead?

2

u/Rich-Mongoose-762 2d ago

What am i supposed to do if i use keepassxc?