From 5eec52989435efacd26ee691ab0ee2e2bf88fe35 Mon Sep 17 00:00:00 2001 From: Timmy Keller Date: Fri, 2 Feb 2024 13:41:55 -0600 Subject: new options for xsudo --- x11/xsudo | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/x11/xsudo b/x11/xsudo index db4a82a..03a01c4 100755 --- a/x11/xsudo +++ b/x11/xsudo @@ -1,8 +1,32 @@ #!/bin/sh + +printhelp() { +cat << HELPDOC " +usage: $(basename "$0") command" +usage: $(basename "$0") [-gh]" + +options: + -g, --get-pass print password to stdout and exit. will output blank if in 'nopass' mode + -h, --help show this help page and exit +HELPDOC +} + +# get password sudo=${SUDO:-sudo} while ! echo "$pass" | $sudo -n true; do pass="$(dmenu -p 'Password: ' <&-)" # Ask user for password pass is incorrect (skipped if nopass in enabled) [ "$pass" = '' ] && exit 0 done + + +# options +[ -z "$1" ] && printhelp && exit 1 + +case "$1" in + -g|--get-pass) printf "$pass" && exit 0 ;; + -h|--help) printhelp && exit 0 ;; +esac + +# xpsuedo magic echo "$pass" | $sudo xauth -f /root/.Xauthority add $(xauth list $DISPLAY) \ && echo "$pass" | $sudo "$@" -- cgit v1.2.3