Skip to content

Commit d037b4d

Browse files
Miles WhittakerBruno Sutic
authored andcommitted
Can now set the ping timeout value
Now use ping's timeout flag instead of wait Checks if OSX and sets to "-t", otherwise "-w". Closes #6
1 parent 990737d commit d037b4d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### master
44
- to speed up the "online test" ping uses only 1 packet
55
- fix issue with status-right and status-left whitespace being cut out
6+
- add ping default timeout (@mjwhitta)
67

78
### v1.0.0, 2014-10-26
89
- README updates

scripts/online_status_icon.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
44

55
online_option_string="@online_icon"
66
offline_option_string="@offline_icon"
7+
ping_timeout_string="@ping_timeout"
78
route_to_ping_string="@route_to_ping"
89

910
online_icon_osx=""
1011
online_icon=""
1112
offline_icon_osx="⛔️ "
1213
offline_icon=""
14+
ping_timeout_default="3"
1315
route_to_ping_default="www.google.com"
1416

1517
source $CURRENT_DIR/shared.sh
@@ -35,7 +37,14 @@ offline_icon_default() {
3537
}
3638

3739
online_status() {
38-
ping -c 1 $(get_tmux_option "$route_to_ping_string" "$route_to_ping_default") >/dev/null 2>&1
40+
if is_osx; then
41+
local timeout_flag="-t"
42+
else
43+
local timeout_flag="-w"
44+
fi
45+
local ping_timeout="$(get_tmux_option "$ping_timeout_string" "$ping_timeout_default")"
46+
local ping_route="$(get_tmux_option "$route_to_ping_string" "$route_to_ping_default")"
47+
ping -c 1 "$timeout_flag" "$ping_timeout" "$ping_route" >/dev/null 2>&1
3948
}
4049

4150
print_icon() {

0 commit comments

Comments
 (0)