From df57825a56f374c11c00cadb086fcfe458870728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Sat, 9 Jan 2016 10:49:50 +0100 Subject: [passmenu] type both --- contrib/dmenu/passmenu | 35 ++++++++++++++++++++++++----------- 1 file 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 -- cgit v1.2.3