dotfiles

Clean dotfiles
git clone git://git.dimitrijedobrota.com/dotfiles.git
Log | Files | Refs

passmenu (826B)


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