Another copy of my dotfiles. Because I don't completely trust GitHub.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.9 KiB

  1. #!/usr/bin/env bash
  2. shopt -s nullglob globstar
  3. typeit=1
  4. if [[ $1 == "--type" ]]; then
  5. typeit=1
  6. shift
  7. fi
  8. prefix=${PASSWORD_STORE_DIR-~/.password-store}
  9. password_files=( "$prefix"/**/*.gpg )
  10. password_files=( "${password_files[@]#"$prefix"/}" )
  11. password_files=( "${password_files[@]%.gpg}" )
  12. # Show urls open in firefox on top
  13. open_urls="$($HOME/.local/bin/exfirefoxtabs.py | awk -F/ '{print $3}' | sort | uniq | sed 's/$//g' | sed ':a;N;$!ba;s/\n/|/g')"
  14. pfiles="$(printf "%s\n" ${password_files[@]})"
  15. list="$(echo "$pfiles" | grep -E "$open_urls")\n$(echo "$pfiles" | grep -Ev "$open_urls")"
  16. entry=$(echo -e "$list" | dmenu -l 7 -p "Pass" -i "$@")
  17. [[ -n $entry ]] || exit
  18. action=$(echo -e "Login\nUsername\nPassword\nTOTP" | dmenu -p "Entry" -i )
  19. case "$action" in
  20. Login)
  21. username=$(echo "$entry" | rev | cut -d"/" -f 1 | rev)
  22. password=$(pass show "$entry")
  23. printf %s "$username" | xargs | xdotool type --clearmodifiers --file -
  24. xdotool key Tab
  25. printf %s "$password" | { IFS= read -r pass; printf %s "$pass"; } | xargs |
  26. xdotool type --clearmodifiers --file -
  27. xdotool key Return
  28. ;;
  29. Username)
  30. username=$(echo "$entry" | rev | cut -d"/" -f 1 | rev)
  31. printf %s "$username" | xclip -selection clipboard
  32. printf %s "$username" | xargs | xdotool type --clearmodifiers --file -
  33. notify-send -a " Password Manager" "Username copied to clipboard";;
  34. Password)
  35. password=$(pass show "$entry")
  36. printf %s "$password" | xclip -selection clipboard
  37. printf %s "$password" | { IFS= read -r pass; printf %s "$pass"; } | xargs |
  38. xdotool type --clearmodifiers --file -
  39. notify-send -a " Password Manager" "Password copied to clipboard";;
  40. TOTP)
  41. otp=$(pass otp "$entry")
  42. printf %s "$otp" | xclip -selection clipboard
  43. printf %s "$otp" | { IFS= read -r pass; printf %s "$pass"; } |
  44. xdotool type --clearmodifiers --file -
  45. notify-send -a " Password Manager" "TOTP copied to clipboard"
  46. xdotool key Return
  47. ;;
  48. esac