diff options
| author | Tyler Hoang <tyler@tylerhoang.xyz> | 2021-11-06 21:07:20 -0700 |
|---|---|---|
| committer | Tyler Hoang <tyler@tylerhoang.xyz> | 2021-11-06 21:07:20 -0700 |
| commit | 3e5458c95c50c06523de4c3cd8dc425f67d4dea5 (patch) | |
| tree | 4d0d6e8e4c8d41b3b3e1b9072ce9b9503d8cd48f /passmenu-otp | |
initial commit
Diffstat (limited to 'passmenu-otp')
| -rwxr-xr-x | passmenu-otp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/passmenu-otp b/passmenu-otp new file mode 100755 index 0000000..9466f32 --- /dev/null +++ b/passmenu-otp @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +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"/}" ) +password_files=( "${password_files[@]%.gpg}" ) + +password=$(printf '%s\n' "${password_files[@]}" | dmenu -i "$@") + +[[ -n $password ]] || exit + +pass_cmd=show +if pass show "$password" | grep -q '^otpauth://'; then + pass_cmd=otp +fi + +if [[ $typeit -eq 0 ]]; then + pass $pass_cmd -c "$password" 2>/dev/null +else + pass $pass_cmd "$password" | { IFS= read -r pass; printf %s "$pass"; } | + xdotool type --clearmodifiers --file - +fi |
