dotfilesClean dotfiles |
git clone git://git.dimitrijedobrota.com/dotfiles.git |
Log | Files | Refs |
otpmenu (813B)
0 #!/usr/bin/env bash 1 2 shopt -s nullglob globstar 3 4 typeit=0 5 if [[ $1 == "--type" ]]; then 6 typeit=1 7 shift 8 fi 9 10 if [[ -n $WAYLAND_DISPLAY ]]; then 11 dmenu=dmenu-wl 12 xdotool="ydotool type --file -" 13 elif [[ -n $DISPLAY ]]; then 14 dmenu=dmenu 15 xdotool="xdotool type --clearmodifiers --file -" 16 else 17 echo "Error: No Wayland or X11 display detected" >&2 18 exit 1 19 fi 20 21 prefix=${PASSWORD_STORE_DIR-~/.password-store} 22 password_files=( "$prefix/otp"/**/*.gpg ) 23 password_files=( "${password_files[@]#"$prefix"/}" ) 24 password_files=( "${password_files[@]%.gpg}" ) 25 26 password=$(printf '%s\n' "${password_files[@]}" | "$dmenu" "$@") 27 28 [[ -n $password ]] || exit 29 30 if [[ $typeit -eq 0 ]]; then 31 pass otp -c "$password" 2>/dev/null 32 else 33 pass otp "$password" | { IFS= read -r pass; printf %s "$pass"; } | $xdotool 34 fi