diff options
-rwxr-xr-x | quicktype | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/quicktype b/quicktype new file mode 100755 index 0000000..b7872e2 --- /dev/null +++ b/quicktype @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# +# Automatically types the username and password from the pass entry specified +# as argument one. The required password-store backend is pass, the standard +# unix password manager. +# +# A simple workflow for this may be to go to a website requiring a username and +# password. Select the username field, open a program launcher such as rofi or +# dmenu, then execute 'quicktype password-name'. +# +# Note that for this to work, each pass entry must match the following criteria +# * The password is on the first line (this is the pass standard) +# * The username can be anywhere in the file, but the line must look like +# 'username: <password>' +# +# Requirements: +# pass +# xdotool +# + +export PASSWORD_STORE_DIR=~/.password-store + + +# Ensure password is specified +[[ -z ${1} ]] && echo "Please specify a password to be typed" && exit 1 + +# Ensure xdotool and pass binaries can be found +[[ ! $(type -p xdotool) ]] && echo "ERROR: xdotool not found." && exit 1 +[[ ! $(type -p pass) ]] && echo "ERROR: pass not found." && exit 1 + +username=$(pass ${@} | sed -n 's/username: \(.*\)/\1/p' | head -n 1) +pass=$(pass ${@} | head -n 1) +xdotool type --delay 15 "${username} ${pass}" |