[PATCH 1/2] passmenu: allow users to override default tool choices
sternenseemann
sternenseemann at systemli.org
Fri Jun 11 18:55:36 UTC 2021
There are multiple different tools users may want to choose for both the
dmenu-like menu program and the xdotool-like “type program” (which we
use for --type).
Especially in the case of dmenu, there are many compatible alternatives
like demnu-wl or bemenu.
For the “type program” there are more or less two alternatives for
wayland we may want to support: ydotool which we currently use, but
employs /dev/uinput, and wtype which has some limitations regarding
Xwayland. Note that as of this commit we would *not* invoke wtype in
a way that works, so wtype support is still pending.
---
contrib/dmenu/passmenu | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/contrib/dmenu/passmenu b/contrib/dmenu/passmenu
index 76d92ab..f0c0d98 100755
--- a/contrib/dmenu/passmenu
+++ b/contrib/dmenu/passmenu
@@ -8,28 +8,33 @@ if [[ $1 == "--type" ]]; then
shift
fi
+# decide which fallback programs to use depending on window system
if [[ -n $WAYLAND_DISPLAY ]]; then
- dmenu=dmenu-wl
- xdotool="ydotool type --file -"
+ def_menu_program=dmenu-wl
+ def_type_program="ydotool type --file -"
elif [[ -n $DISPLAY ]]; then
- dmenu=dmenu
- xdotool="xdotool type --clearmodifiers --file -"
+ def_menu_program=dmenu
+ def_type_program="xdotool type --clearmodifiers --file -"
else
echo "Error: No Wayland or X11 display detected" >&2
exit 1
fi
+# respect user's choice
+PASSWORD_STORE_MENU_PROGRAM=${PASSWORD_STORE_MENU_PROGRAM:-$def_menu_program}
+PASSWORD_STORE_TYPE_PROGRAM=${PASSWORD_STORE_TYPE_PROGRAM:-$def_type_program}
+
prefix=${PASSWORD_STORE_DIR-~/.password-store}
password_files=( "$prefix"/**/*.gpg )
password_files=( "${password_files[@]#"$prefix"/}" )
password_files=( "${password_files[@]%.gpg}" )
-password=$(printf '%s\n' "${password_files[@]}" | "$dmenu" "$@")
+password=$(printf '%s\n' "${password_files[@]}" | "$PASSWORD_STORE_MENU_PROGRAM" "$@")
[[ -n $password ]] || exit
if [[ $typeit -eq 0 ]]; then
pass show -c "$password" 2>/dev/null
else
- pass show "$password" | { IFS= read -r pass; printf %s "$pass"; } | $xdotool
+ pass show "$password" | { IFS= read -r pass; printf %s "$pass"; } | $PASSWORD_STORE_TYPE_PROGRAM
fi
--
2.31.1
More information about the Password-Store
mailing list