diff --git a/scripts/network.sh b/scripts/network.sh index 883212ef..6faeb36f 100755 --- a/scripts/network.sh +++ b/scripts/network.sh @@ -2,7 +2,11 @@ # setting the locale, some users have issues with different locales, this forces the correct one export LC_ALL=en_US.UTF-8 -HOSTS="google.com github.com example.com" +current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $current_dir/utils.sh + +# set your own hosts so that a wifi is recognised even without internet access +HOSTS=$(get_tmux_option "@dracula-network-hosts" "google.com github.com example.com") get_ssid() { @@ -11,17 +15,18 @@ get_ssid() Linux) SSID=$(iw dev | sed -nr 's/^\t\tssid (.*)/\1/p') if [ -n "$SSID" ]; then - printf '%s' "$SSID" + printf '%s' "$wifi_label$SSID" else - echo 'Ethernet' + echo "$(get_tmux_option "@dracula-network-ethernet-label" "Ethernet")" fi ;; Darwin) if networksetup -getairportnetwork en0 | cut -d ':' -f 2 | sed 's/^[[:blank:]]*//g' &> /dev/null; then - echo "$(networksetup -getairportnetwork en0 | cut -d ':' -f 2)" | sed 's/^[[:blank:]]*//g' + wifi_label=$(get_tmux_option "@dracula-network-wifi-label" "") + echo "$wifi_label$(networksetup -getairportnetwork en0 | cut -d ':' -f 2)" | sed 's/^[[:blank:]]*//g' else - echo 'Ethernet' + echo "$(get_tmux_option "@dracula-network-ethernet-label" "Ethernet")" fi ;; @@ -37,7 +42,7 @@ get_ssid() main() { - network="Offline" + network="$(get_tmux_option "@dracula-network-offline-label" "Offline")" for host in $HOSTS; do if ping -q -c 1 -W 1 $host &>/dev/null; then network="$(get_ssid)"