set icons directly in output for waybar
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"fmt"
|
||||
"github.com/prometheus-community/pro-bing"
|
||||
"math"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -23,8 +22,6 @@ var (
|
||||
|
||||
type WaybarOut struct {
|
||||
Class string `json:"class"`
|
||||
PackageLoss string `json:"package_loss"`
|
||||
Ping string `json:"ping"`
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
Reference in New Issue
Block a user