m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2014-06-29 11:35:03 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2014-06-29 11:41:15 +0200
commit326a12c9bf8f8b8a703c8a518c035f547524e01e (patch)
tree4c5e4fbfecf7e547fdc616b6e9c888a326223a67 /contrib
parentb300dd8f97a6d1d5ed914fedcba3e79604cd7e87 (diff)
passmenu: type text with xdotool
Suggested-by: Christoph Egger <christoph@christoph-egger.org>
Diffstat (limited to 'contrib')
-rw-r--r--contrib/dmenu/README.md6
-rwxr-xr-xcontrib/dmenu/passmenu14
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