[PATCH] Add wtype as a typer

jimum3bxg6c4 at gmail.com jimum3bxg6c4 at gmail.com
Thu Oct 3 20:15:38 UTC 2024


From: cedric <gaspotrash at gmail.com>

There are cases where wtype is prefered over ydotool.
There might be also cases where ydotool can be prefered in an X11
environment.

This patch allows the user to choose which typer to use, among:
- xdotool
- ydotool
- wtype

It is also fully backward compatible.

passmenu --type          # will work exactly as previously
passmenu --type wtype    # will choose wtype as typer
passmenu --type ydotool  # will choose ydotool even in a X11 environment
---
 contrib/dmenu/README.md |  6 +++++-
 contrib/dmenu/passmenu  | 22 +++++++++++++++++-----
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/contrib/dmenu/README.md b/contrib/dmenu/README.md
index 8a196cb..eda9dd5 100644
--- a/contrib/dmenu/README.md
+++ b/contrib/dmenu/README.md
@@ -8,9 +8,12 @@ On wayland [dmenu-wl][] is used to replace dmenu and [ydotool][] to replace xdot
 Note that the latter requires access to the [uinput][] device, so you'll probably
 need to add an extra udev rule or similar to give certain non-root users permission.
 
+Optionally you can force a typer (xdotool, ydotool or wtype) by adding it as a
+parameter to `--type`. e.g.: `passmenu --type wtype`.
+
 # Usage
 
-    passmenu [--type] [dmenu arguments...]
+    passmenu [--type [xdotool|ydotool|wtype]] [dmenu arguments...]
 
 [dmenu]: http://tools.suckless.org/dmenu/
 [xdotool]: http://www.semicomplete.com/projects/xdotool/
@@ -18,3 +21,4 @@ need to add an extra udev rule or similar to give certain non-root users permiss
 [dmenu-wl]: https://github.com/nyyManni/dmenu-wayland
 [ydotool]: https://github.com/ReimuNotMoe/ydotool
 [uinput]: https://www.kernel.org/doc/html/v4.12/input/uinput.html
+[wtype]: https://github.com/atx/wtype
diff --git a/contrib/dmenu/passmenu b/contrib/dmenu/passmenu
index 76d92ab..599c7ff 100755
--- a/contrib/dmenu/passmenu
+++ b/contrib/dmenu/passmenu
@@ -3,17 +3,29 @@
 shopt -s nullglob globstar
 
 typeit=0
-if [[ $1 == "--type" ]]; then
-	typeit=1
-	shift
+unset xdotool
+
+if [[ "$1" == "--type" ]]; then
+    typeit=1
+    shift
+    if [[ "$1" == "xdotool" ]]; then
+        xdotool="xdotool type --clearmodifiers --file -"
+        shift
+    elif [[ "$1" == "ydotool" ]]; then 
+        xdotool="ydotool type --file -"
+        shift
+    elif [[ "$1" == "wtype" ]]; then 
+        xdotool="wtype -"
+        shift
+    fi
 fi
 
 if [[ -n $WAYLAND_DISPLAY ]]; then
 	dmenu=dmenu-wl
-	xdotool="ydotool type --file -"
+	: ${xdotool:="ydotool type --file -"}
 elif [[ -n $DISPLAY ]]; then
 	dmenu=dmenu
-	xdotool="xdotool type --clearmodifiers --file -"
+	: ${xdotool:="xdotool type --clearmodifiers --file -"}
 else
 	echo "Error: No Wayland or X11 display detected" >&2
 	exit 1
-- 
2.46.2



More information about the Password-Store mailing list