m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/contrib/dmenu
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/dmenu')
-rw-r--r--contrib/dmenu/README.md10
-rwxr-xr-xcontrib/dmenu/passmenu15
2 files changed, 23 insertions, 2 deletions
diff --git a/contrib/dmenu/README.md b/contrib/dmenu/README.md
index cc810e2..b4bc81d 100644
--- a/contrib/dmenu/README.md
+++ b/contrib/dmenu/README.md
@@ -19,9 +19,19 @@ If `--otp-pattern REGEXP` is specified, password IDs matching the regular
expression will be interpreted as secrets for OTP-style two-factor
authentication. When used with `--otp`, only OTP password IDs will be displayed.
+On wayland [dmenu-wl][] is used to replace dmenu and [ydotool][] to replace xdotool.
+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.
+
+# Usage
+
+
passmenu [--type] [--otp] [--infer-otp] [--otp-pattern <regexp>] [dmenu arguments...]
[dmenu]: http://tools.suckless.org/dmenu/
[xdotool]: http://www.semicomplete.com/projects/xdotool/
[pass]: http://www.zx2c4.com/projects/password-store/
+[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
[pass-otp]: https://github.com/tadfisher/pass-otp
diff --git a/contrib/dmenu/passmenu b/contrib/dmenu/passmenu
index bb8e7d6..e5635fd 100755
--- a/contrib/dmenu/passmenu
+++ b/contrib/dmenu/passmenu
@@ -20,6 +20,17 @@ while [[ $# -gt 0 && $finish -eq 0 ]]; do
[[ $finish -eq 0 ]] && shift
done
+if [[ -n $WAYLAND_DISPLAY ]]; then
+ dmenu=dmenu-wl
+ xdotool="ydotool type --file -"
+elif [[ -n $DISPLAY ]]; then
+ dmenu=dmenu
+ xdotool="xdotool type --clearmodifiers --file -"
+else
+ echo "Error: No Wayland or X11 display detected" >&2
+ exit 1
+fi
+
prefix=${PASSWORD_STORE_DIR-~/.password-store}
password_files=( "$prefix"/**/*.gpg )
password_files=( "${password_files[@]#"$prefix"/}" )
@@ -33,7 +44,7 @@ if [[ $otp -eq 1 ]]; then
password_files=(${filtered_files[@]})
fi
-password=$(printf '%s\n' "${password_files[@]}" | dmenu "$@")
+password=$(printf '%s\n' "${password_files[@]}" | "$dmenu" "$@")
[[ -n $password ]] || exit
@@ -50,5 +61,5 @@ if [[ $typeit -eq 0 ]]; then
pass $otp_arg show -c "$password" 2>/dev/null
else
pass $otp_arg show "$password" | { IFS= read -r pass; printf %s "$pass"; } |
- xdotool type --clearmodifiers --file -
+ $xdotool
fi