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:
parent
ad15679588
commit
265149ca11
3
main.go
3
main.go
@ -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
20
modules/power/settings.go
Normal 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
|
||||
}
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user