From b151eabb82a5f37e4d597d4d6d5662f8520fc171 Mon Sep 17 00:00:00 2001 From: Ezri Date: Fri, 12 Apr 2024 11:47:50 -0600 Subject: [PATCH] VPN toggle --- ...ame.tycho => 20-vpn.conf##class.uses-usu-vpn} | 0 .config/sway/workspaces.json##hostname.rocinante | 2 +- .config/zsh/utils.zsh | 16 +++++++++++++++- .local/bin/vpn-toggle | 14 ++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) rename .config/sway/local-config.d/{20-vpn.conf##hostname.tycho => 20-vpn.conf##class.uses-usu-vpn} (100%) create mode 100755 .local/bin/vpn-toggle diff --git a/.config/sway/local-config.d/20-vpn.conf##hostname.tycho b/.config/sway/local-config.d/20-vpn.conf##class.uses-usu-vpn similarity index 100% rename from .config/sway/local-config.d/20-vpn.conf##hostname.tycho rename to .config/sway/local-config.d/20-vpn.conf##class.uses-usu-vpn diff --git a/.config/sway/workspaces.json##hostname.rocinante b/.config/sway/workspaces.json##hostname.rocinante index d13e73d..78acfb7 100644 --- a/.config/sway/workspaces.json##hostname.rocinante +++ b/.config/sway/workspaces.json##hostname.rocinante @@ -19,7 +19,7 @@ "exec": "firefox", "args": ["--new-window"], "environ": { - "MOZ_ENABLE_WAYLAND": "1" + "MOZ_ENABLE_WAYLAND": "0" }, "program_name": "firefox" }, diff --git a/.config/zsh/utils.zsh b/.config/zsh/utils.zsh index d840f7f..b502c99 100644 --- a/.config/zsh/utils.zsh +++ b/.config/zsh/utils.zsh @@ -13,7 +13,21 @@ function getkernelpkg() { } function random-xkcd() { - curl $(curl -L https://c.xkcd.com/random/comic/ 2>/dev/null | (echo "https:"$(xmllint --html --xpath 'string(//html/body/div[@id="middleContainer"]/div[@id="comic"]/img/@src)' - 2>/dev/null))) | feh - + blocklist=( + "404" + "631" # "Anatomy Text", don't want that coming up in public thanks + ) + link="https://xkcd.com/404/" + while (( $blocklist[(Ie)$(basename $link)] )); do + link=$(curl https://c.xkcd.com/random/comic/ -v |& grep location | cut -d' ' -f3 | sed 's/\r//') + done + html=$(curl -L ${link/http:/https:} 2>/dev/null) + name=$(echo $html | xmllint --html --xpath 'string(//html/body/div[@id="middleContainer"]/div[@id="ctitle"])' - 2>/dev/null) + title=$(echo $html | xmllint --html --xpath 'string(//html/body/div[@id="middleContainer"]/div[@id="comic"]/img/@title)' - 2>/dev/null) + echo $link + echo -e "\033[1;34m$name\033[0m" + echo -e "\033[1;33m$title\033[0m" + curl $(echo $html | (echo "https:"$(xmllint --html --xpath 'string(//html/body/div[@id="middleContainer"]/div[@id="comic"]/img/@src)' - 2>/dev/null))) 2>/dev/null | feh - } if [[ $(hostnamectl chassis) == "container" ]]; then diff --git a/.local/bin/vpn-toggle b/.local/bin/vpn-toggle new file mode 100755 index 0000000..4fa36ba --- /dev/null +++ b/.local/bin/vpn-toggle @@ -0,0 +1,14 @@ +#!/usr/bin/env zsh + +# Toggles the GlobalProtect VPN connection on and off + +# Get the current state of the VPN connection +if pgrep gpclient &>/dev/null; then + # VPN is connected, so disconnect + echo "Disconnecting from VPN..." + pkexec gpclient disconnect +else + # VPN is disconnected, so connect + echo "Connecting to VPN..." + pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY gpclient connect gp.usu.edu +fi