summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xcontrib/dmenu/passmenu35
1 files changed, 24 insertions, 11 deletions
diff --git a/contrib/dmenu/passmenu b/contrib/dmenu/passmenu
index 2cc9364..702eeb1 100755
--- a/contrib/dmenu/passmenu
+++ b/contrib/dmenu/passmenu
@@ -3,22 +3,26 @@
shopt -s nullglob globstar
typeit=0
-if [[ $1 == "--type" ]]; then
- typeit=1
- shift
-fi
user=
-if [[ $1 == "--user" ]]; then
- user=-u
- shift
-fi
+both=0
+
+while [[ $# -gt 0 ]]; do
+ case $1 in
+ "--type") typeit=1; shift;;
+ "--user") user=-u; shift;;
+ "--both") both=1; shift;;
+ *) break;;
+ esac
+done
if [[ -n $WAYLAND_DISPLAY ]]; then
dmenu=dmenu-wl
- xdotool="ydotool type --file -"
+ _xdotool=ydotool
+ xdotool="$_xdotool type --file -"
elif [[ -n $DISPLAY ]]; then
dmenu=dmenu
- xdotool="xdotool type --clearmodifiers --file -"
+ _xdotool=xdotool
+ xdotool="$_xdotool type --clearmodifiers --file -"
else
echo "Error: No Wayland or X11 display detected" >&2
exit 1
@@ -33,8 +37,17 @@ password=$(printf '%s\n' "${password_files[@]}" | "$dmenu" "$@")
[[ -n $password ]] || exit
+xdo() {
+ local user=$1
+ pass show $user "$password" | { IFS= read -r pass; printf %s "$pass"; } | $xdotool
+}
+
if [[ $typeit -eq 0 ]]; then
pass show $user -c "$password" 2>/dev/null
+elif [[ $both -eq 0 ]]; then
+ xdo $user
else
- pass show $user "$password" | { IFS= read -r pass; printf %s "$pass"; } | $xdotool
+ xdo
+ $_xdotool key Tab
+ xdo -u
fi