commit 98fdfdab4c6f532ccef8c0ad3a2f33e1a692d879 parent f9e459847610ae2f250a05399cf58a44a588ec12 Author: Jake Koroman <jakekoroman@gmail.com> Date: Sun, 31 Mar 2024 20:53:48 -0400 add my passmenu-otp config Diffstat:
A | scripts/passmenu-otp | | | 30 | ++++++++++++++++++++++++++++++ |
1 file changed, 30 insertions(+), 0 deletions(-)
diff --git a/scripts/passmenu-otp b/scripts/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[@]}" | bemenu -l 8 -w -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