Skip to content

Commit a50e530

Browse files
authored
Merge pull request #1566 from Joshfindit/patch-1
Update bandwidth_primary.1s.sh
2 parents c14dffe + 4986d52 commit a50e530

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

Network/bandwidth_primary.1s.sh

100755100644
+5-8
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@
44
# <xbar.version>v0.0.1</xbar.version>
55
# <xbar.author>Kaspars Mickevics</xbar.author>
66
# <xbar.author.github>fxlv</xbar.author.github>
7-
# <xbar.desc>Displays bandwidth usage for the primary interface in Megabits/s</xbar.desc>
7+
# <xbar.desc>Displays bandwidth usage for a network interface in Megabits/s</xbar.desc>
88
# <xbar.dependencies>ifstat</xbar.dependencies>
99
# <xbar.image>https://cloud.githubusercontent.com/assets/2462211/12748504/584bbcea-c9b3-11e5-8109-ad8fdcefdc75.png</xbar.image>
10+
# <xbar.var>string(VAR_NETWORK_INTERFACE="en0"): The interface to track (Usual interface for MacOS wifi is en0)</xbar.var>
1011

1112
# based on bandwidth.1s.sh by Ant Cosentino
1213

13-
# only gather stats from interface en0
14-
# no need to samlpe unused interfaces
15-
INTERFACE="en0"
16-
1714

1815
if [ ! -e /usr/local/bin/ifstat ]; then
1916
echo "Please install ifstat or change the path to it in the script."
@@ -26,10 +23,10 @@ function kilo_to_mega {
2623
}
2724

2825
function get_ifstat {
29-
interface=$1
26+
IFSTAT_INTERFACE=$1
3027
# 1 sample for 0.5 second interval
3128
# outputs two values (in/out) in kilobits per second
32-
/usr/local/bin/ifstat -n -w -i "${interface}" -b 0.5 1 | tail -n 1
29+
/usr/local/bin/ifstat -n -w -i "${IFSTAT_INTERFACE}" -b 0.5 1 | tail -n 1
3330
}
3431

3532
function print_ifstat {
@@ -41,5 +38,5 @@ function print_ifstat {
4138

4239
}
4340

44-
print_ifstat "$(get_ifstat ${INTERFACE})"
41+
print_ifstat "$(get_ifstat ${VAR_NETWORK_INTERFACE})"
4542
echo "---"

0 commit comments

Comments
 (0)