hlctl/notifyctl/notify.go

34 lines
670 B
Go
Raw Normal View History

2023-01-07 16:56:15 +00:00
package notifyctl
import (
"strconv"
"sectorinf.com/emilis/hlctl/ctllog"
"sectorinf.com/emilis/hlctl/hlcl"
)
var log = ctllog.Logger{}.New("notify", ctllog.ColorRGB{}.FromHex("ff003e"))
func Display(message string, duration uint, fg, bg, font string) error {
width, err := hlcl.TextWidth(font, message)
if err != nil {
log.Errorf("%s; defaulting to width 100", err.Error())
width = "100"
}
widthNum, err := strconv.ParseUint(width, 10, 8)
if err != nil {
panic(err)
}
return hlcl.Dzen2(
message,
"-p", strconv.Itoa(int(duration)),
"-fg", fg,
"-bg", bg,
"-fn", font,
"-ta", "c",
"-w", strconv.Itoa(int(widthNum)+30),
"-h", "16",
)
}