From a582047e7e32929ac81ac31697867c1d73117766 Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Sat, 3 Aug 2024 16:16:05 -0800 Subject: [PATCH] Add login-to-wifi.sh --- login-to-wifi.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 login-to-wifi.sh diff --git a/login-to-wifi.sh b/login-to-wifi.sh new file mode 100755 index 0000000..a2143ba --- /dev/null +++ b/login-to-wifi.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env zsh + +# Find the default route +default_route="$(ip route | grep '^default' | grep -Po '(?<=via )[^ ]+')" + +if (( ${?} != 0 )); then + printf '\e[91merror\e[m: could not get default route\n' + exit 1 +fi + +# Reverse lookup the default route (idk why, it works sometimes) +login_addr="$(mullvad-exclude host "${default_route}" "${default_route}" | awk 'NR==6 { print $4 }')" + +if (( ${?} != 0)); then + login_addr="${default_route}" +fi + +exec mullvad-exclude firejail --dns="${default_route}" \ + firefox --new-instance --no-remote "${login_addr}"