mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
41 lines
694 B
Go
41 lines
694 B
Go
package power
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/andrewzolotukhin/wtf/wtf"
|
|
"github.com/olebedev/config"
|
|
)
|
|
|
|
// Config is a pointer to the global config object
|
|
var Config *config.Config
|
|
|
|
type Widget struct {
|
|
wtf.TextWidget
|
|
|
|
Battery *Battery
|
|
}
|
|
|
|
func NewWidget() *Widget {
|
|
widget := Widget{
|
|
TextWidget: wtf.NewTextWidget(" Power ", "power", false),
|
|
Battery: NewBattery(),
|
|
}
|
|
|
|
widget.View.SetWrap(true)
|
|
|
|
return &widget
|
|
}
|
|
|
|
func (widget *Widget) Refresh() {
|
|
widget.UpdateRefreshedAt()
|
|
widget.Battery.Refresh()
|
|
|
|
str := ""
|
|
str = str + fmt.Sprintf(" %10s: %s\n", "Source", powerSource())
|
|
str = str + "\n"
|
|
str = str + widget.Battery.String()
|
|
|
|
widget.View.SetText(fmt.Sprintf("%s", str))
|
|
}
|