summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2016-01-09 10:49:50 +0100
committerRené 'Necoro' Neumann <necoro@necoro.eu>2021-06-24 00:00:23 +0200
commitdf57825a56f374c11c00cadb086fcfe458870728 (patch)
treeee9e0dd2ac9e2d54fe4d9d32fe64859ca620e869
parent76ae5c35d9fdb8a5a7ea8e5c51fb4e92b87f5f0e (diff)
downloadpass-df57825a56f374c11c00cadb086fcfe458870728.tar.gz
pass-df57825a56f374c11c00cadb086fcfe458870728.tar.bz2
pass-df57825a56f374c11c00cadb086fcfe458870728.zip
[passmenu] type both
-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