dm-passmenu-name.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/usr/bin/env bash
  2. # Colors:
  3. # # Materia Manjaro
  4. # nf='#09dbc9'
  5. # nb='#222b2e'
  6. # sf='#dbdcd5'
  7. # sb='#009185'
  8. # Everforest
  9. nf='#d3c6aa'
  10. nb='#2d353b'
  11. sf='#a7c080'
  12. sb='#475258'
  13. fn='Iosevka-18:normal'
  14. # fn='Ubuntu-16:normal'
  15. # Gruvbox
  16. # nf='#fea63c'
  17. # nb='#282828'
  18. # # sf='#dbdcd5'
  19. # sb='#d79921'
  20. # fn='Sarasa Mono SC Nerd-17:normal'
  21. # shopt -s nullglob globstar
  22. if [[ -n $WAYLAND_DISPLAY ]]; then
  23. DMENU=dmenu-wl
  24. xdotool="ydotool type --file -"
  25. elif [[ -n $DISPLAY ]]; then
  26. DMENU="dmenu -i -l 10 -nf ${nf} -nb ${nb} -sf ${sf} -sb ${sb} -fn ${fn} -p"
  27. xdotool="xdotool type --clearmodifiers --file -"
  28. else
  29. echo "Error: No Wayland or X11 display detected" >&2
  30. exit 1
  31. fi
  32. prefix=${PASSWORD_STORE_DIR-~/.password-store}
  33. password_files=( "$prefix"/**/*.gpg )
  34. password_files=( "${password_files[@]#"$prefix"/}" )
  35. password_files=( "${password_files[@]%.gpg}" )
  36. # password=$(printf '%s\n' "${password_files[@]}" | "$dmenu" "$@")
  37. username=$(printf '%s\n' "${password_files[@]}" | ${DMENU} 'Username for:')
  38. # username=$(printf '%s\n' "${password_files[@]}" | "$dmenu" -i -l 10 -nf ${nf} -nb ${nb} -sf ${sf} -sb ${sb} -fn ${fn} -p 'Username for:')
  39. [[ -n $username ]] || exit
  40. got_username=$(pass show $username | grep "username:" | awk '{print $2}')
  41. if [[ -z $got_username ]]; then
  42. notify-send -t 5000 -i dialog-information "$username" "doesn't have a 'username:' field."
  43. else
  44. for_notify=$(echo $username | cut -d "/" -f2)
  45. echo $got_username | xclip -selection clipboard
  46. notify-send -t 5000 -i dialog-information "Copied $for_notify to clipboard.
  47. Will clear in 45 seconds."
  48. sleep 45
  49. cat /dev/null | xclip -sel clip
  50. notify-send -t 5000 -i dialog-information "Cleared."
  51. fi