m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/contrib/dmenu
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/dmenu')
-rw-r--r--contrib/dmenu/README.md11
-rwxr-xr-xcontrib/dmenu/passmenu12
2 files changed, 23 insertions, 0 deletions
diff --git a/contrib/dmenu/README.md b/contrib/dmenu/README.md
new file mode 100644
index 0000000..8160b3c
--- /dev/null
+++ b/contrib/dmenu/README.md
@@ -0,0 +1,11 @@
+`passmenu` is a [dmenu][]-based interface to [pass][], the standard Unix
+password manager. This design allows you to quickly copy a password to the
+clipboard without having to open up a terminal window if you don't already have
+one open.
+
+# Usage
+
+ passmenu [dmenu arguments...]
+
+[dmenu]: http://tools.suckless.org/dmenu/
+[pass]: http://www.zx2c4.com/projects/password-store/
diff --git a/contrib/dmenu/passmenu b/contrib/dmenu/passmenu
new file mode 100755
index 0000000..5d9d454
--- /dev/null
+++ b/contrib/dmenu/passmenu
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+shopt -s nullglob globstar
+
+prefix=${PASSWORD_STORE_DIR-~/.password-store}
+password_files=( "$prefix"/**/*.gpg )
+password_files=( "${password_files[@]#"$prefix"/}" )
+password_files=( "${password_files[@]%.gpg}" )
+
+password=$(printf '%s\n' "${password_files[@]}" | dmenu "$@")
+
+[ $? -eq 0 ] && pass -c "$password"