Skip to content

Commit

Permalink
WTF-400 Power extracted to new config format
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Cummer committed Apr 16, 2019
1 parent ad15679 commit 265149c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
3 changes: 2 additions & 1 deletion main.go
Expand Up @@ -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":
Expand Down
20 changes: 20 additions & 0 deletions modules/power/settings.go
@@ -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
}
9 changes: 6 additions & 3 deletions modules/power/widget.go
Expand Up @@ -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)
Expand Down

0 comments on commit 265149c

Please sign in to comment.