Guest User

Untitled

a guest
Feb 17th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. shopt -s nullglob globstar
  2.  
  3. # settings
  4. typeDelay=30
  5. user=0
  6.  
  7. while [ -n "$1" ]; do
  8. case "$1" in
  9. --user) user=1; shift;;
  10. *) break;;
  11. esac
  12. done
  13.  
  14. function typeEnter() {
  15. xdotool key --delay $typeDelay Return
  16. }
  17.  
  18. prefix=${PASSWORD_STORE_DIR-~/.password-store}
  19. password_files=( "$prefix"/**/*.gpg )
  20. password_files=( "${password_files[@]#"$prefix"/}" )
  21. password_files=( "${password_files[@]%.gpg}" )
  22.  
  23. password_name=$(printf '%s\n' "${password_files[@]}" | dmenu "$@")
  24.  
  25. [[ -n $password_name ]] || exit
  26.  
  27. lines="$(pass show "$password_name" 2>/dev/null)"
  28.  
  29. password="$(echo "$lines" | head -n1 )"
  30. username="$(echo "$lines" | sed -n "s/^username\:[[:blank:]]*\(.*\)$/\1/p")"
  31.  
  32. function typeText() {
  33. echo -n "$@" | xdotool type --clearmodifiers --delay $typeDelay --file -
  34. }
  35.  
  36. if [[ $user -eq 1 ]]; then
  37. typeText "$username"
  38. xdotool key --delay $typeDelay Tab
  39. fi
  40. typeText "$password"
Add Comment
Please, Sign In to add comment