pfr Adding xterm -class Pinentry -e to the beginning of the program[passmenu] line wont work (actually, it doesn't work) as it begins the sequence with an xterm rather than beginning with passmenu.sh piped through dmenu.
I'm afraid you've lost me. This should've worked as follows:
- MOD + Shift + p triggers
xterm -e.
xterm runs passmenu.sh inside a pseudo-tty--which is what's needed for pass to work.
passmenu.sh gathers a list of .gpg files--which are site labels--belonging to pass and echoes them to dmenu.
dmenu creates a menu from input read from stdin.
- You choose which site's password you want to extract.
- Site name is passed to
pass which runs inside xterm.
pass contacts gpg-agent to retrieve password (PIN) for decryption of chosen site.
gpg-agent runs pinentry-curses to ask PIN for decryption. (All of this is running inside the xterm we've launched.)
pinentry-curses creates a dialog box, reads PIN, hands back PIN to gpg-agent; which in turn sends it on to pass.
pass uses PIN to decrypt site file which holds password; reads this password and either :
a) copies this to the clipboard -- the -c option, or,
b) writes password to xdotool, which simulates a user typing the password into some input box.
Which step is failing here?
If you want passmenu.sh to be run directly on MOD + Shift + p instead of via xterm you can do it by splitting the original passmenu.sh file into 2 pieces. Otherwise, the shell quoting needed to run pass inside xterm becomes a little hairy.
This is piece one, passmenu.sh. Make it executable and call this without xterm -e:
#!/usr/bin/env bash
shopt -s nullglob globstar
typeit=0
if [[ $1 == "--type" ]]; then
typeit=1
shift
fi
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 "$@")
[[ -n $password ]] || exit
xterm -class Pinentry -e ~/bin/run-pass.sh "$typeit" "$password"
Piece two, run-pass.sh, gets called from passmenu.sh. Put this file in ~/bin; make it executable chmod 755 ~/bin/run-pass.sh:
#!/usr/bin/env bash
if [[ $# -ne 2 ]]
then printf '%s: needs 2 arguments\n' $0 1>&2
exit 1
fi
typeit=$1
password=$2
if [[ $typeit -eq 0 ]]; then
pass show -c "$password" 2>/dev/null
else
pass show "$password" | { IFS= read -r pass; printf %s "$pass"; } |
xdotool type --clearmodifiers --file -
fi
This works slightly differently from what I've outlined above, but, you should be able to figure it out easily. See if this works.