passmenu: --type-fully

Alexander Weickmann alexander.weickmann at link-time.com
Sun Jul 7 22:46:46 CEST 2019


Added another flag to passmenu:

--type-fully: will first type the username (whatever is found on second 
line), then a Tab key, followed by the password,
    another Tab key and finally a Return key

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.

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.

#!/usr/bin/env bash

shopt -s nullglob globstar

typeit=0

typeitFully=0

if [[ $1 == "--type" ]]; then

     typeit=1

     shift

elif [[ $1 == "--type-fully" ]]; then

     typeitFully=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

type_username() {

     pass show "$password" | head -n 2 | tail -n 1 | { IFS= read -r pass; printf %s "$pass"; } |

         xdotool type --clearmodifiers --file -

}

type_password() {

     pass show "$password" | { IFS= read -r pass; printf %s "$pass"; } |

         xdotool type --clearmodifiers --file -

}

if [[ $typeit -eq 0 ]] && [[ $typeitFully -eq 0 ]]; then

     pass show -c "$password" 2>/dev/null

elif [[ $typeit -eq 1 ]]; then

     type_password

elif [[ $typeitFully -eq 1 ]]; then

     type_username

     xdotool key Tab

     type_password

     xdotool key Tab

     xdotool key Return

fi

Regards,
Alex

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20190707/8df84fca/attachment.html>


More information about the Password-Store mailing list