summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xkeyboard/shutdownprompt2
-rwxr-xr-xkeyboard/wgconnect40
-rwxr-xr-xmisc/dnfu6
-rwxr-xr-xx11/xsudo24
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"
diff --git a/misc/dnfu b/misc/dnfu
index a7ab85c..9f6a9cb 100755
--- a/misc/dnfu
+++ b/misc/dnfu
@@ -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
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 "$@"