set icons directly in output for waybar
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/prometheus-community/pro-bing"
|
"github.com/prometheus-community/pro-bing"
|
||||||
"math"
|
"math"
|
||||||
"strconv"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -23,8 +22,6 @@ var (
|
|||||||
|
|
||||||
type WaybarOut struct {
|
type WaybarOut struct {
|
||||||
Class string `json:"class"`
|
Class string `json:"class"`
|
||||||
PackageLoss string `json:"package_loss"`
|
|
||||||
Ping string `json:"ping"`
|
|
||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,8 +62,8 @@ func formatLine(stats *probing.Statistics) {
|
|||||||
func formatLineWaybar(stats *probing.Statistics) {
|
func formatLineWaybar(stats *probing.Statistics) {
|
||||||
res := new(WaybarOut)
|
res := new(WaybarOut)
|
||||||
|
|
||||||
res.PackageLoss = strconv.Itoa(int(math.Round(stats.PacketLoss)))
|
res.Text = fmt.Sprintf("\uE4E2 %dms \uF1B2 %d%%", int(stats.AvgRtt.Milliseconds()), int(math.Round(stats.PacketLoss)))
|
||||||
res.Ping = strconv.Itoa(int(stats.AvgRtt.Milliseconds()))
|
res.Class = "good"
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case int(math.Round(stats.PacketLoss)) > *PacketLossWarnLimit || int(stats.AvgRtt.Milliseconds()) > *PingWarningLimit:
|
case int(math.Round(stats.PacketLoss)) > *PacketLossWarnLimit || int(stats.AvgRtt.Milliseconds()) > *PingWarningLimit:
|
||||||
|
Reference in New Issue
Block a user