<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Added another flag to passmenu:</p>
    <p>--type-fully: will first type the username (whatever is found on
      second line), then a Tab key, followed by the password,<br>
         another Tab key and finally a Return key</p>
    <p>I often have a different username on services I use. Auto-typing
      the password is a huge time saver, but then I still need to look
      up the username, or copy it to clipboard using pass -c2. The
      --type-fully parameter for passmenu is meant to make the login
      process fully automated.</p>
    <p>There is a risk that the user's password will be exposed on
      screen if the form does not change input focus from username field
      to password on Tab key. But I think user's can assess this risk
      for themselves and decide whether they want to use the flag or
      not. In the end, many GUI password managers offer the same
      functionality, with same risk.</p>
    <pre>#!/usr/bin/env bash</pre>
    <pre>shopt -s nullglob globstar</pre>
    <pre>typeit=0</pre>
    <pre>typeitFully=0</pre>
    <pre>if [[ $1 == "--type" ]]; then</pre>
    <pre>    typeit=1</pre>
    <pre>    shift</pre>
    <pre>elif [[ $1 == "--type-fully" ]]; then</pre>
    <pre>    typeitFully=1</pre>
    <pre>    shift</pre>
    <pre>fi</pre>
    <pre>prefix=${PASSWORD_STORE_DIR-~/.password-store}</pre>
    <pre>password_files=( "$prefix"/**/*.gpg )</pre>
    <pre>password_files=( "${password_files[@]#"$prefix"/}" )</pre>
    <pre>password_files=( <a class="moz-txt-link-rfc2396E" href="mailto:${password_files[@]%.gpg}">"${password_files[@]%.gpg}"</a> )</pre>
    <pre>password=$(printf '%s\n' "${password_files[@]}" | dmenu "$@")</pre>
    <pre>[[ -n $password ]] || exit</pre>
    <pre>type_username() {</pre>
    <pre>    pass show "$password" | head -n 2 | tail -n 1 | { IFS= read -r pass; printf %s "$pass"; } |</pre>
    <pre>        xdotool type --clearmodifiers --file -</pre>
    <pre>}</pre>
    <pre>type_password() {</pre>
    <pre>    pass show "$password" | { IFS= read -r pass; printf %s "$pass"; } |</pre>
    <pre>        xdotool type --clearmodifiers --file -</pre>
    <pre>}</pre>
    <pre>if [[ $typeit -eq 0 ]] && [[ $typeitFully -eq 0 ]]; then</pre>
    <pre>    pass show -c "$password" 2>/dev/null</pre>
    <pre>elif [[ $typeit -eq 1 ]]; then</pre>
    <pre>    type_password</pre>
    <pre>elif [[ $typeitFully -eq 1 ]]; then</pre>
    <pre>    type_username</pre>
    <pre>    xdotool key Tab</pre>
    <pre>    type_password</pre>
    <pre>    xdotool key Tab</pre>
    <pre>    xdotool key Return</pre>
    <pre>fi</pre>
    Regards,<br>
    Alex
    <div class="moz-signature"><font style="line-height:130%" size="2"
        face="Arial,Helvetica,sans-serif" color="#888888"><br>
      </font> </div>
  </body>
</html>