[pass] [passmenu] [PATCH] Add option to type both username and password

Simon Lackerbauer simon at lackerbauer.com
Sun Dec 6 15:57:18 CET 2015


Hi,

I'd like to add optional functionality to passmenu to type both username
and password via xdotool (--typeboth): essentially, with this one gets a
one-hit fill out function for forms on websites in all cases where you
usually also type username, tab, password yourself.

Naturally, if you want to use this function, it adds an additional
restriction on how the first two lines of pass files are to be
formatted. If files only have a password line or the second line is
empty, it works just like --type. If the second line, however, is not
the username in that instance, using this option could lead to
unexpected behavior.

Tell me what you think.

---
 contrib/dmenu/README.md |  6 ++++--
 contrib/dmenu/passmenu  | 19 ++++++++++++++++---
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/contrib/dmenu/README.md b/contrib/dmenu/README.md
index 9d54fb4..55f44c0 100644
--- a/contrib/dmenu/README.md
+++ b/contrib/dmenu/README.md
@@ -2,11 +2,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.
+instead of copied to the clipboard. If `--typeboth` is specified the
second
+line is typed using [xdotool][] first (ideally the username), then tab,
then
+the first line.

 # Usage

-    passmenu [--type] [dmenu arguments...]
+    passmenu [--type | --typeboth] [dmenu arguments...]

 [dmenu]: http://tools.suckless.org/dmenu/
 [xdotool]: http://www.semicomplete.com/projects/xdotool/
diff --git a/contrib/dmenu/passmenu b/contrib/dmenu/passmenu
index 9b5239d..97a5332 100755
--- a/contrib/dmenu/passmenu
+++ b/contrib/dmenu/passmenu
@@ -8,6 +8,12 @@ if [[ $1 == "--type" ]]; then
  shift
 fi

+typeboth=0
+if [[ $1 == "--typeboth" ]]; then
+ typeboth=1
+ shift
+fi
+
 prefix=${PASSWORD_STORE_DIR-~/.password-store}
 password_files=( "$prefix"/**/*.gpg )
 password_files=( "${password_files[@]#"$prefix"/}" )
@@ -17,10 +23,17 @@ password=$(printf '%s\n' "${password_files[@]}" |
dmenu "$@")

 [[ -n $password ]] || exit

-if [[ $typeit -eq 0 ]]; then
- pass show -c "$password" 2>/dev/null
-else
+if [[ $typeit -eq 1 ]]; then
+ pass show "$password" |
+   awk 'BEGIN{ORS=""} {print; exit}' |
+   xdotool type --clearmodifiers --file -
+elif [[ $typeboth -eq 1 ]]; then
+ pass show "$password" |
+   awk 'BEGIN{ORS="\t"} NR==2 {print; exit}' |
+   xdotool type --clearmodifiers --file -
  pass show "$password" |
    awk 'BEGIN{ORS=""} {print; exit}' |
    xdotool type --clearmodifiers --file -
+else
+    pass show -c "$password" 2>/dev/null
 fi
-- 
2.6.2

-- 
www.lackerbauer.com
B0CB 1DB6 C2E5 8167 4CB4  2136 564A DEDA 01BD 6EFA

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20151206/6655d106/attachment.asc>


More information about the Password-Store mailing list