Add login-to-wifi.sh

This commit is contained in:
Alexander Rosenberg 2024-08-03 16:16:05 -08:00
parent 1d1e6469ba
commit a582047e7e
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730

19
login-to-wifi.sh Executable file
View File

@ -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}"