blob: b7872e2680e91f193da5d538bb04bb33eb1461b9 (
plain)
1 #!/usr/bin/env bash
2 #
3 # Automatically types the username and password from the pass entry specified
4 # as argument one. The required password-store backend is pass, the standard
5 # unix password manager.
6 #
7 # A simple workflow for this may be to go to a website requiring a username and
8 # password. Select the username field, open a program launcher such as rofi or
9 # dmenu, then execute 'quicktype password-name'.
10 #
11 # Note that for this to work, each pass entry must match the following criteria
12 # * The password is on the first line (this is the pass standard)
13 # * The username can be anywhere in the file, but the line must look like
14 # 'username: <password>'
15 #
16 # Requirements:
17 # pass
18 # xdotool
19 #
20
21 export PASSWORD_STORE_DIR=~/.password-store
22
23
24 # Ensure password is specified
25 [[ -z ${1} ]] && echo "Please specify a password to be typed" && exit 1
26
27 # Ensure xdotool and pass binaries can be found
28 [[ ! $(type -p xdotool) ]] && echo "ERROR: xdotool not found." && exit 1
29 [[ ! $(type -p pass) ]] && echo "ERROR: pass not found." && exit 1
30
31 username=$(pass ${@} | sed -n 's/username: \(.*\)/\1/p' | head -n 1)
32 pass=$(pass ${@} | head -n 1)
33 xdotool type --delay 15 "${username} ${pass}"
|