1
0
Fork 0
chezmoi/dot_config/herbstluftwm/executable_passmenu2
2022-05-06 10:08:57 +02:00

30 lines
751 B
Bash

#!/usr/bin/env bash
shopt -s nullglob globstar
if (( ROFI_RETV == 0 ))
then
echo -en "\0prompt\x1fPassword for\n"
prefix=${PASSWORD_STORE_DIR-~/.password-store}
password_files=( "$prefix"/**/*.gpg )
password_files=( "${password_files[@]#"$prefix"/}" )
password_files=( "${password_files[@]%.gpg}" )
printf '%s\n' "${password_files[@]}"
else
typeit=0
(( ROFI_RETV == 2 )) && typeit=1
password="$1"
echo "$@" >&2
echo "$ROFI_RETV" >&2
[[ -n $password ]] || exit
if (( typeit == 0 ))
then
coproc pass show -c "$password" &>/dev/null
else
coproc ( pass show "$password" | { read -r pass; printf %s "$pass"; } |
xdotool type --clearmodifiers --file - )
fi
fi