From 3b4590b1a745b06ce36cb558a4749923675e9b35 Mon Sep 17 00:00:00 2001 From: Jake Koroman Date: Sun, 1 Jun 2025 10:55:23 -0400 Subject: Ready. Set. Go! --- scripts/passmenu-otp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 scripts/passmenu-otp (limited to 'scripts/passmenu-otp') diff --git a/scripts/passmenu-otp b/scripts/passmenu-otp new file mode 100755 index 0000000..379fd8f --- /dev/null +++ b/scripts/passmenu-otp @@ -0,0 +1,32 @@ +#!/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}" ) + +# dmenu_cmd="wofi_style --show dmenu $@" +dmenu_cmd="dmenu -l 12 -i $@" +password=$(printf '%s\n' "${password_files[@]}" | $dmenu_cmd) + +[[ -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 -- cgit v1.2.3