diff options
-rwxr-xr-x | keyboard/shutdownprompt | 2 | ||||
-rwxr-xr-x | keyboard/wgconnect | 40 | ||||
-rwxr-xr-x | misc/dnfu | 6 | ||||
-rwxr-xr-x | x11/xsudo | 24 |
4 files changed, 68 insertions, 4 deletions
diff --git a/keyboard/shutdownprompt b/keyboard/shutdownprompt index db65489..ce187a8 100755 --- a/keyboard/shutdownprompt +++ b/keyboard/shutdownprompt @@ -1,6 +1,6 @@ #!/bin/sh dmenucolors='-nb #AA0000 -nf #FFF -sb #FF0000 -sf #FFF' -[ -n "$1" ] && option="$1" || option=$(echo "Cancel\nSuspend\nShutdown\nRestart" | dmenu -p "Power Menu " $dmenucolors || exit) +[ -n "$1" ] && option="$1" || option=$(printf "Cancel\nSuspend\nShutdown\nRestart" | dmenu -p "Power Menu " $dmenucolors || exit) warn_process_names="ffmpeg obs dvgrab dnf xbps-install xbps-remove emerge apt pacman" diff --git a/keyboard/wgconnect b/keyboard/wgconnect new file mode 100755 index 0000000..de8f307 --- /dev/null +++ b/keyboard/wgconnect @@ -0,0 +1,40 @@ +#!/bin/sh +# Connect to/disconnect from wireguard tunnel using dmenu + +sudo="${SUDO:-sudo}" +pass="$(xsudo --get-pass)" + +ssudo() { echo "$pass" | $sudo $@ ; } + +dmenu_confirm_continue() { + case "$(echo "yes\nno" | dmenu -p "$1")" in + yes) + ;; + *) exit 0 ;; + esac +} + +curtun="$(ssudo wg show | sed 's/interface: //;q')" + +# Ask to disconnect from current interface +if [ -n "$curtun" ]; then + dmenu_confirm_continue "Currently connected to tunnel $curtun. Disconnect?" + + output="$(ssudo wg-quick down "$curtun" 2>&1)" + notify-send "Disconnected from $curtun" "$output" + + dmenu_confirm_continue "Connect to another interface?" +fi + +# Connect to new interface +tundir=/etc/wireguard + +tun="$tundir/$(ssudo ls "$tundir" | grep "\.conf$" | dmenu -p "Connect to which tunnel?")" + +if ! ssudo cat $tun >/dev/null 2>/dev/null; then + notify-send "Couldn't connect to tunnel $tun" + exit 1 +fi + +output="$(ssudo wg-quick up "$tun" 2>&1)" +notify-send "Connected to $tun" "$output" @@ -1,10 +1,10 @@ #!/bin/sh sudo ln -sf /bin/bash /bin/sh -sudo dnf update +sudo dnf update $@ -sudo dnf remove --oldinstallonly --setopt installonly_limit=2 kernel +sudo dnf remove $@ --oldinstallonly --setopt installonly_limit=2 kernel -sudo dnf autoremove +sudo dnf autoremove $@ sudo ln -sf /bin/dash /bin/sh @@ -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 "$@" |