diff --git a/ping-package.go b/ping-package.go index 87ae1d5..fa05751 100644 --- a/ping-package.go +++ b/ping-package.go @@ -6,7 +6,6 @@ import ( "fmt" "github.com/prometheus-community/pro-bing" "math" - "strconv" "time" ) @@ -22,10 +21,8 @@ var ( ) type WaybarOut struct { - Class string `json:"class"` - PackageLoss string `json:"package_loss"` - Ping string `json:"ping"` - Text string `json:"text"` + Class string `json:"class"` + Text string `json:"text"` } func formatLine(stats *probing.Statistics) { @@ -65,8 +62,8 @@ func formatLine(stats *probing.Statistics) { func formatLineWaybar(stats *probing.Statistics) { res := new(WaybarOut) - res.PackageLoss = strconv.Itoa(int(math.Round(stats.PacketLoss))) - res.Ping = strconv.Itoa(int(stats.AvgRtt.Milliseconds())) + res.Text = fmt.Sprintf("\uE4E2 %dms \uF1B2 %d%%", int(stats.AvgRtt.Milliseconds()), int(math.Round(stats.PacketLoss))) + res.Class = "good" switch { case int(math.Round(stats.PacketLoss)) > *PacketLossWarnLimit || int(stats.AvgRtt.Milliseconds()) > *PingWarningLimit: