Skip to content

Commit 6e3e5bf

Browse files
Merge pull request #300 from Theoreticallyhugo/bug/no-wifi-icon-on-linux
Bug/no wifi icon on linux
2 parents 75ba88e + 1325b49 commit 6e3e5bf

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

scripts/network.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ source $current_dir/utils.sh
77

88
# set your own hosts so that a wifi is recognised even without internet access
99
HOSTS=$(get_tmux_option "@dracula-network-hosts" "google.com github.com example.com")
10+
wifi_label=$(get_tmux_option "@dracula-network-wifi-label" "")
11+
ethernet_label=$(get_tmux_option "@dracula-network-ethernet-label" "Ethernet")
1012

1113
get_ssid()
1214
{
@@ -15,18 +17,17 @@ get_ssid()
1517
Linux)
1618
SSID=$(iw dev | sed -nr 's/^\t\tssid (.*)/\1/p')
1719
if [ -n "$SSID" ]; then
18-
printf '%s' "$wifi_label$SSID"
20+
echo "$wifi_label$SSID"
1921
else
20-
echo "$(get_tmux_option "@dracula-network-ethernet-label" "Ethernet")"
22+
echo "$ethernet_label"
2123
fi
2224
;;
2325

2426
Darwin)
2527
if networksetup -getairportnetwork en0 | cut -d ':' -f 2 | sed 's/^[[:blank:]]*//g' &> /dev/null; then
26-
wifi_label=$(get_tmux_option "@dracula-network-wifi-label" "")
2728
echo "$wifi_label$(networksetup -getairportnetwork en0 | cut -d ':' -f 2)" | sed 's/^[[:blank:]]*//g'
2829
else
29-
echo "$(get_tmux_option "@dracula-network-ethernet-label" "Ethernet")"
30+
echo "$ethernet_label"
3031
fi
3132
;;
3233

@@ -44,7 +45,7 @@ main()
4445
{
4546
network="$(get_tmux_option "@dracula-network-offline-label" "Offline")"
4647
for host in $HOSTS; do
47-
if ping -q -c 1 -W 1 $host &>/dev/null; then
48+
if ping -q -c 1 -W 1 "$host" &>/dev/null; then
4849
network="$(get_ssid)"
4950
break
5051
fi

scripts/utils.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
#!/usr/bin/env bash
22

33
get_tmux_option() {
4-
local option=$1
5-
local default_value=$2
6-
local option_value=$(tmux show-option -gqv "$option")
4+
local option="$1"
5+
local default_value="$2"
6+
local option_value="$(tmux show-option -gqv "$option")"
77
if [ -z "$option_value" ]; then
8-
echo $default_value
8+
echo "$default_value"
99
else
10-
echo $option_value
10+
echo "$option_value"
1111
fi
1212
}
1313

1414
get_tmux_window_option() {
15-
local option=$1
16-
local default_value=$2
17-
local option_value=$(tmux show-window-options -v "$option")
15+
local option="$1"
16+
local default_value="$2"
17+
local option_value="$(tmux show-window-options -v "$option")"
1818
if [ -z "$option_value" ]; then
19-
echo $default_value
19+
echo "$default_value"
2020
else
21-
echo $option_value
21+
echo "$option_value"
2222
fi
2323
}
2424

0 commit comments

Comments
 (0)