1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

WTF-400 Power extracted to new config format

This commit is contained in:
Chris Cummer 2019-04-15 21:38:10 -07:00
parent ad15679588
commit 265149ca11
3 changed files with 28 additions and 4 deletions

View File

@ -261,7 +261,8 @@ func makeWidget(app *tview.Application, pages *tview.Pages, widgetName string) w
case "pagerduty":
widget = pagerduty.NewWidget(app)
case "power":
widget = power.NewWidget(app)
settings := power.NewSettingsFromYAML(wtf.Config)
widget = power.NewWidget(app, settings)
case "prettyweather":
widget = prettyweather.NewWidget(app)
case "resourceusage":

20
modules/power/settings.go Normal file
View File

@ -0,0 +1,20 @@
package power
import (
"github.com/olebedev/config"
"github.com/wtfutil/wtf/cfg"
)
type Settings struct {
common *cfg.Common
filePath string
}
func NewSettingsFromYAML(ymlConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromYAML(ymlConfig),
}
return &settings
}

View File

@ -10,13 +10,16 @@ import (
type Widget struct {
wtf.TextWidget
Battery *Battery
Battery *Battery
settings *Settings
}
func NewWidget(app *tview.Application) *Widget {
func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: wtf.NewTextWidget(app, "Power", "power", false),
Battery: NewBattery(),
Battery: NewBattery(),
settings: settings,
}
widget.View.SetWrap(true)