passmenu-otp (741B)
1 #!/usr/bin/env bash 2 3 shopt -s nullglob globstar 4 5 typeit=0 6 if [[ $1 == "--type" ]]; then 7 typeit=1 8 shift 9 fi 10 11 prefix=${PASSWORD_STORE_DIR-~/.password-store} 12 password_files=( "$prefix"/**/*.gpg ) 13 password_files=( "${password_files[@]#"$prefix"/}" ) 14 password_files=( "${password_files[@]%.gpg}" ) 15 16 # dmenu_cmd="wofi_style --show dmenu $@" 17 dmenu_cmd="dmenu -l 12 -i $@" 18 password=$(printf '%s\n' "${password_files[@]}" | $dmenu_cmd) 19 20 [[ -n $password ]] || exit 21 22 pass_cmd=show 23 if pass show "$password" | grep -q '^otpauth://'; then 24 pass_cmd=otp 25 fi 26 27 if [[ $typeit -eq 0 ]]; then 28 pass $pass_cmd -c "$password" 2>/dev/null 29 else 30 pass $pass_cmd "$password" | { IFS= read -r pass; printf %s "$pass"; } | 31 xdotool type --clearmodifiers --file - 32 fi