diff options
-rw-r--r-- | contrib/dmenu/README.md | 6 | ||||
-rwxr-xr-x | contrib/dmenu/passmenu | 14 |
2 files changed, 17 insertions, 3 deletions
diff --git a/contrib/dmenu/README.md b/contrib/dmenu/README.md index 8160b3c..9d54fb4 100644 --- a/contrib/dmenu/README.md +++ b/contrib/dmenu/README.md @@ -1,11 +1,13 @@ `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. +one open. If `--type` is specified, the password is typed using [xdotool][] +instead of copied to the clipboard. # Usage - passmenu [dmenu arguments...] + passmenu [--type] [dmenu arguments...] [dmenu]: http://tools.suckless.org/dmenu/ +[xdotool]: http://www.semicomplete.com/projects/xdotool/ [pass]: http://www.zx2c4.com/projects/password-store/ diff --git a/contrib/dmenu/passmenu b/contrib/dmenu/passmenu index 8ecb41f..a0da173 100755 --- a/contrib/dmenu/passmenu +++ b/contrib/dmenu/passmenu @@ -2,6 +2,12 @@ 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"/}" ) @@ -9,4 +15,10 @@ password_files=( "${password_files[@]%.gpg}" ) password=$(printf '%s\n' "${password_files[@]}" | dmenu "$@") -[[ -n $password ]] && pass show -c "$password" 2>/dev/null +[[ -n $password ]] || exit + +if [[ $typeit -eq 0 ]]; then + pass show -c "$password" 2>/dev/null +else + xdotool - <<<"type --clearmodifiers -- $(pass show "$password" | head -n 1)" +fi |