[PATCH 2/2] Add environment variables to configure passmenu.

c4llv07e igor at c4llv07e.xyz
Tue Apr 16 20:30:15 UTC 2024


Passmenu now allows to replace `dmenu` and `xdotool` executables with
user's choice using `PASSMENU_DMENU` and `PASSMENU_XDOTOOL`
environment variables
---

There are too many dmenu-like launchers on Linux. Let users choose one
instead of using the default one.

But it has some problems. I couldn't find a good way to pass arguments
through environment variables without using `sh -c` and `eval`.
Therefore, users would have to create a custom script in the PATH to
customize it.

I couldn't think of a better names for this variables. Maybe it sould
use `PASS_` namespace, but I don't know.

 contrib/dmenu/README.md | 6 ++++++
 contrib/dmenu/passmenu  | 8 ++++++++
 2 files changed, 14 insertions(+)

diff --git a/contrib/dmenu/README.md b/contrib/dmenu/README.md
index c261023..bc99547 100644
--- a/contrib/dmenu/README.md
+++ b/contrib/dmenu/README.md
@@ -12,6 +12,12 @@ need to add an extra udev rule or similar to give certain non-root users permiss
 
     passmenu [--type] [dmenu arguments...]
 
+# Configuration
+
+    `PASSMENU_DMENU` - The executable that will be used instead of dmenu.
+
+    `PASSMENU_XDOTOOL` - The executable that will be used to type a password.
+
 [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 e7b6309..44ebb05 100755
--- a/contrib/dmenu/passmenu
+++ b/contrib/dmenu/passmenu
@@ -19,6 +19,14 @@ else
 	exit 1
 fi
 
+if [[ -n ${PASSMENU_DMENU} ]]; then
+	dmenu=${PASSMENU_DMENU}
+fi
+
+if [[ -n $PASSMENU_XDOTOOL ]]; then
+	xdotool=${PASSMENU_XDOTOOL}
+fi
+
 prefix=${PASSWORD_STORE_DIR-~/.password-store}
 password_files=( "$prefix"/**/*.gpg )
 password_files=( "${password_files[@]#"$prefix"/}" )
-- 
2.44.0



More information about the Password-Store mailing list