Hi Amir,

Here you can find the new patch, I think this is reasonably generic to let one 
use an arbitrary 
command without adding an additional dependency.


In data mercoledì 12 settembre 2018 12:27:56 CEST, Amir Yalon ha scritto:


Hi Alessandro,


One problem that I can see with this patch is that the pass-otp extension is 
not distributed as 
part of pass. Maybe it could be generalised to specify any alternative 
sub-command to 
substitute for `show`.






On Wed, Sep 12, 2018, at 13:10, Alessandro Accardo wrote:


Here you can find the (smallest as possible) patch in attachment, I hope you


can include it in the sources, I think this will be extremely useful for every


person who uses 2FA with unix-pass and a dmenu interface.


 






>From 196e7cc85d463bfcdcee04b63293cb54bedb8b10 Mon Sep 17 00:00:00 2001
From: Alessandro Accardo <[email protected]>
Date: Wed, 12 Sep 2018 18:45:56 +0200
Subject: [PATCH] Added the ability to use an arbitrary command

---
 contrib/dmenu/README.md |  4 +++-
 contrib/dmenu/passmenu  | 10 ++++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/contrib/dmenu/README.md b/contrib/dmenu/README.md
index 9d54fb4..83e03b5 100644
--- a/contrib/dmenu/README.md
+++ b/contrib/dmenu/README.md
@@ -3,11 +3,13 @@ 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. If `--type` is specified, the password is typed using [xdotool][]
 instead of copied to the clipboard.
+If a custom command is needed (e.g. in order to use [pass-otp][]) a `--cmd` option can be passed with the custom command as the argument.
 
 # Usage
 
-    passmenu [--type] [dmenu arguments...]
+    passmenu [--type] [--cmd <command>] [dmenu arguments...]
 
 [dmenu]: http://tools.suckless.org/dmenu/
 [xdotool]: http://www.semicomplete.com/projects/xdotool/
 [pass]: http://www.zx2c4.com/projects/password-store/
+[pass-otp]: https://github.com/tadfisher/pass-otp#readme
diff --git a/contrib/dmenu/passmenu b/contrib/dmenu/passmenu
index 83268bc..e19f73b 100755
--- a/contrib/dmenu/passmenu
+++ b/contrib/dmenu/passmenu
@@ -3,10 +3,16 @@
 shopt -s nullglob globstar
 
 typeit=0
+cmd="show"
 if [[ $1 == "--type" ]]; then
 	typeit=1
 	shift
 fi
+if [[ $1 == "--cmd" ]]; then
+	shift
+	cmd="$1"
+	shift
+fi
 
 prefix=${PASSWORD_STORE_DIR-~/.password-store}
 password_files=( "$prefix"/**/*.gpg )
@@ -18,8 +24,8 @@ password=$(printf '%s\n' "${password_files[@]}" | dmenu "$@")
 [[ -n $password ]] || exit
 
 if [[ $typeit -eq 0 ]]; then
-	pass show -c "$password" 2>/dev/null
+	pass $cmd -c "$password" 2>/dev/null
 else
-	pass show "$password" | { IFS= read -r pass; printf %s "$pass"; } |
+	pass $cmd "$password" | { IFS= read -r pass; printf %s "$pass"; } |
 		xdotool type --clearmodifiers --file -
 fi
-- 
2.16.4

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Password-Store mailing list
[email protected]
https://lists.zx2c4.com/mailman/listinfo/password-store

Reply via email to