[gopass] Ensure default variables are set
This commit is contained in:
parent
6fe0b66bd1
commit
03e8b3b9b5
1 changed files with 40 additions and 18 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
# typing tool used, choice of:
|
# typing tool used, choice of:
|
||||||
# xdotool |
|
# xdotool |
|
||||||
BACKEND=xdotool
|
# BACKEND=xdotool
|
||||||
|
|
||||||
# the complete typing chain autoentry uses
|
# the complete typing chain autoentry uses
|
||||||
# possible fields:
|
# possible fields:
|
||||||
|
|
@ -18,15 +18,20 @@ BACKEND=xdotool
|
||||||
# By default it enters the username, tabs down, and enters the password
|
# By default it enters the username, tabs down, and enters the password
|
||||||
# It does not press return at the end for safety, though you can add
|
# It does not press return at the end for safety, though you can add
|
||||||
# :return to make it do so.
|
# :return to make it do so.
|
||||||
AUTOENTRY_CHAIN="username :tab password"
|
# AUTOENTRY_CHAIN="username :tab password"
|
||||||
|
|
||||||
# wait time before entering each input
|
# wait time before entering each input
|
||||||
# in milliseconds
|
# in milliseconds
|
||||||
AUTOENTRY_DELAY=20
|
# AUTOENTRY_DELAY=20
|
||||||
|
|
||||||
# default key bindings
|
# default key bindings
|
||||||
# Automatically enter username and password
|
# Automatically enter username and password
|
||||||
KEY_AUTOENTRY="Return"
|
# KEY_AUTOENTRY="Return"
|
||||||
|
|
||||||
|
# The field name containing your gopass username
|
||||||
|
# can take multiple names, separated by space
|
||||||
|
# Will go through names in descending precedence
|
||||||
|
# GOPASS_USERNAME_FIELD="username user login"
|
||||||
|
|
||||||
# rofi wrapper. Add custom settings here.
|
# rofi wrapper. Add custom settings here.
|
||||||
_rofi() {
|
_rofi() {
|
||||||
|
|
@ -53,31 +58,48 @@ _gp_show_password() {
|
||||||
gopass show -f --password "$1"
|
gopass show -f --password "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
GOPASS_USERNAME_ATTEMPTS="username user login"
|
|
||||||
|
|
||||||
# return username for argument passed
|
|
||||||
_gp_show_username() {
|
|
||||||
for key in $GOPASS_USERNAME_ATTEMPTS; do
|
|
||||||
|
|
||||||
done
|
|
||||||
gopass show -f "$1" username || gopass -f show "$1" user || gopass -f show "$1" login
|
|
||||||
}
|
|
||||||
|
|
||||||
# send password to clipboard
|
# send password to clipboard
|
||||||
_gp_clip_password() {
|
_gp_clip_password() {
|
||||||
gopass show -c "$1"
|
gopass show -c "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# attempt to return the field specified
|
||||||
|
# attempts all (space separated) fields until the
|
||||||
|
# first one successfully returned
|
||||||
|
_gp_get_field() {
|
||||||
|
local gp_entry="$1"
|
||||||
|
local gp_field="$2"
|
||||||
|
local gp_opt="$3"
|
||||||
|
|
||||||
|
for key in $gp_field; do
|
||||||
|
# return on first successfully returned key
|
||||||
|
if [ -n "$gp_opt" ]; then
|
||||||
|
gopass show "$gp_opt" -f "$gp_entry" "$key" && break
|
||||||
|
else
|
||||||
|
gopass show -f "$gp_entry" "$key" && break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# return username for argument passed
|
||||||
|
_gp_show_username() {
|
||||||
|
_gp_get_field "$1" "${GOPASS_USERNAME_FIELD:-"username user login"}"
|
||||||
|
}
|
||||||
|
|
||||||
|
_gp_clip_username() {
|
||||||
|
_gp_get_field "$1" "${GOPASS_USERNAME_FIELD:-"username user login"}" "-c"
|
||||||
|
}
|
||||||
|
|
||||||
# invoke the dotool to type inputs
|
# invoke the dotool to type inputs
|
||||||
_type() {
|
_type() {
|
||||||
local tool
|
local tool
|
||||||
local toolmode
|
local toolmode
|
||||||
local key
|
local key
|
||||||
tool="${BACKEND}"
|
tool="${BACKEND:-xdotool}"
|
||||||
toolmode="$1"
|
toolmode="$1"
|
||||||
key="$2"
|
key="$2"
|
||||||
|
|
||||||
"$tool" "$toolmode" --delay "$AUTOENTRY_DELAY" "$key"
|
"$tool" "$toolmode" --delay "${AUTOENTRY_DELAY:-20}" "$key"
|
||||||
}
|
}
|
||||||
|
|
||||||
# automatically enter entry chain, set via AUTOENTRY_CHAIN
|
# automatically enter entry chain, set via AUTOENTRY_CHAIN
|
||||||
|
|
@ -86,7 +108,7 @@ autoentry() {
|
||||||
local selected
|
local selected
|
||||||
local autoentry_chain
|
local autoentry_chain
|
||||||
selected="${1}"
|
selected="${1}"
|
||||||
autoentry_chain="${AUTOENTRY_CHAIN}"
|
autoentry_chain="${AUTOENTRY_CHAIN:-username :tab password}"
|
||||||
|
|
||||||
for part in $autoentry_chain; do
|
for part in $autoentry_chain; do
|
||||||
case "$part" in
|
case "$part" in
|
||||||
|
|
@ -103,7 +125,7 @@ autoentry() {
|
||||||
main() {
|
main() {
|
||||||
# entry="$(list_passwords | _rofi -kb-accept-entry "" -kb-custom-1 "${key_autotype}" -kb-custom-2 "${key_usertype}" -kb-custom-3 "${key_passtype}" -kb-custom-4 "${key_actions}" -mesg "${key_autotype}: Autotype | ${key_usertype}: Type User | ${key_passtype}: Type Pass | ${key_actions}: More Actions")"
|
# entry="$(list_passwords | _rofi -kb-accept-entry "" -kb-custom-1 "${key_autotype}" -kb-custom-2 "${key_usertype}" -kb-custom-3 "${key_passtype}" -kb-custom-4 "${key_actions}" -mesg "${key_autotype}: Autotype | ${key_usertype}: Type User | ${key_passtype}: Type Pass | ${key_actions}: More Actions")"
|
||||||
|
|
||||||
entry="$(_gp_list_passwords | _rofi -kb-accept-entry "" -kb-custom-1 "${KEY_AUTOENTRY}")"
|
entry="$(_gp_list_passwords | _rofi -kb-accept-entry "" -kb-custom-1 "${KEY_AUTOENTRY:-Return}")"
|
||||||
exit_value=$?
|
exit_value=$?
|
||||||
|
|
||||||
exit_check "${exit_value}"
|
exit_check "${exit_value}"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue