1
0
Fork 0
mirror of https://github.com/Horhik/dotfiles.git synced 2024-11-30 03:51:28 +00:00
Dotfiles/.config/polybar/polybar-scripts/info-pingrtt/info-pingrtt.sh

20 lines
392 B
Bash
Raw Normal View History

2020-07-27 04:59:00 +00:00
#!/bin/sh
HOST=127.43.12.64
if ! ping=$(ping -n -c 1 -W 1 $HOST); then
echo "# ping failed"
else
rtt=$(echo "$ping" | sed -rn 's/.*time=([0-9]{1,})\.?[0-9]{0,} ms.*/\1/p')
if [ "$rtt" -lt 50 ]; then
icon="%{F#3cb703}#%{F-}"
elif [ "$rtt" -lt 150 ]; then
icon="%{F#f9dd04}#%{F-}"
else
icon="%{F#d60606}#%{F-}"
fi
echo "$icon $rtt ms"
fi