[gopass] Add reading options from config file
File can be used to alter the functions of rofi-gopass.
This commit is contained in:
parent
87031b8ce7
commit
75397a0bb2
2 changed files with 47 additions and 16 deletions
|
|
@ -26,6 +26,8 @@
|
|||
# default key bindings
|
||||
# Automatically enter username and password
|
||||
# KEY_AUTOFILL="Return"
|
||||
# Open entry
|
||||
# KEY_OPEN_ENTRY
|
||||
# Automatically enter username only
|
||||
# KEY_FILL_USER="Alt+u"
|
||||
# Add username to clipboard
|
||||
|
|
@ -47,6 +49,9 @@
|
|||
# Will go through names in descending precedence
|
||||
# GOPASS_USERNAME_FIELD="username user login"
|
||||
|
||||
# The location of the rofi-gopass config file
|
||||
# ROFI_PASS_CONFIGURATION_FILE="~/.config/rofi-gopass"
|
||||
|
||||
# rofi wrapper. Add custom settings here.
|
||||
_rofi() {
|
||||
# TODO add check for dmenu
|
||||
|
|
@ -54,6 +59,25 @@ _rofi() {
|
|||
rofi -dmenu -no-auto-select -i "$@" -p "Entry"
|
||||
}
|
||||
|
||||
# read config file
|
||||
get_config_file() {
|
||||
local locations=("$ROFI_PASS_CONFIGURATION_FILE"
|
||||
"${XDG_CONFIG_HOME:-$HOME/.config}/rofi-gopass/rofi-gopass.conf"
|
||||
"$HOME/.rofi-gopass.conf"
|
||||
"/etc/rofi-gopass.conf")
|
||||
|
||||
# return the first config file with a valid path
|
||||
for config in "${locations[@]}"; do
|
||||
if [[ -n "$config" && -f "$config" ]]; then
|
||||
# we only source config values, don't complain
|
||||
# shellcheck disable=SC1090
|
||||
source "$config"
|
||||
echo "sourced config"
|
||||
return
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# exit on escape pressed
|
||||
# rofi returns exit code 1 on esc
|
||||
exit_check() {
|
||||
|
|
@ -198,7 +222,7 @@ main() {
|
|||
local k_clip_user="${KEY_CLIP_USER:-Ctrl+Alt+u}"
|
||||
local k_fill_pass="${KEY_FILL_PASS:-Alt+p}"
|
||||
local k_clip_pass="${KEY_CLIP_PASS:-Ctrl+Alt+p}"
|
||||
local k_submenu="${KEY_CLIP_PASS:-Alt+Return}"
|
||||
local k_submenu="${KEY_OPEN_ENTRY:-Alt+Return}"
|
||||
|
||||
entry="$(
|
||||
list_passwords |
|
||||
|
|
@ -242,4 +266,5 @@ main() {
|
|||
esac
|
||||
}
|
||||
|
||||
get_config_file
|
||||
main
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue