diff options
author | Timmy Keller <tjk@tjkeller.xyz> | 2024-02-02 13:41:55 -0600 |
---|---|---|
committer | Timmy Keller <tjk@tjkeller.xyz> | 2024-02-02 13:41:55 -0600 |
commit | 5eec52989435efacd26ee691ab0ee2e2bf88fe35 (patch) | |
tree | 81ba4c68b267e665e9fdda44d799ee09b02d2868 /x11/xsudo | |
parent | 8f090b64df29dcf1c882c6855829abddedb2951f (diff) | |
download | scripts-5eec52989435efacd26ee691ab0ee2e2bf88fe35.tar.xz scripts-5eec52989435efacd26ee691ab0ee2e2bf88fe35.zip |
new options for xsudo
Diffstat (limited to 'x11/xsudo')
-rwxr-xr-x | x11/xsudo | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -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 "$@" |