From 5f47b1644d4dd4c045c22145c093c9e919281b2a Mon Sep 17 00:00:00 2001 From: Emma Date: Tue, 30 Jan 2024 11:16:57 -0800 Subject: [PATCH] add a way to detect network interface on macOS - typically returns en0, or if a VPN is on it will most likely show one of the `utun` interfaces --- scripts/network_bandwidth.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/network_bandwidth.sh b/scripts/network_bandwidth.sh index 939052a..b560812 100755 --- a/scripts/network_bandwidth.sh +++ b/scripts/network_bandwidth.sh @@ -26,6 +26,11 @@ interface_get() { name="$(ip -o route get 192.168.0.0 | awk '{print $5}')" fi ;; + Darwin) + if type route >/dev/null; then + name="$(route -n get 192.168.0.0 2>/dev/null | awk '/interface: / {print $2}')" + fi + ;; esac fi