[PATCH v2 1/3] passmenu: allow users to override default tool choices

sternenseemann sternenseemann at systemli.org
Fri Jun 11 22:26:01 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.
---

Added Documentation in the README.md in this patch version.

 contrib/dmenu/README.md |  8 ++++++++
 contrib/dmenu/passmenu  | 17 +++++++++++------
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/contrib/dmenu/README.md b/contrib/dmenu/README.md
index 8a196cb..4b13e5b 100644
--- a/contrib/dmenu/README.md
+++ b/contrib/dmenu/README.md
@@ -12,6 +12,14 @@ need to add an extra udev rule or similar to give certain non-root users permiss
 
     passmenu [--type] [dmenu arguments...]
 
+# Configuration
+
+You can influence the behavior of `passmenu` via the following environment variables:
+
+* `PASSWORD_STORE_MENU_PROGRAM`: A `dmenu`-compatible menu tool
+* `PASSWORD_STORE_TYPE_PROGRAM`: A command that accepts a password via `stdin`
+  and inputs it as if it were the user (used when `--type` is given)
+
 [dmenu]: http://tools.suckless.org/dmenu/
 [xdotool]: http://www.semicomplete.com/projects/xdotool/
 [pass]: http://www.zx2c4.com/projects/password-store/
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