diff --git a/main.go b/main.go index 17b10f3b..6a627e11 100644 --- a/main.go +++ b/main.go @@ -276,14 +276,15 @@ func makeWidget(app *tview.Application, pages *tview.Pages, widgetName string) w case "security": settings := security.NewSettingsFromYAML(wtf.Config) widget = security.NewWidget(app, settings) + case "spotify": + settings := spotify.NewSettingsFromYAML(wtf.Config) + widget = spotify.NewWidget(app, pages, settings) + case "spotifyweb": + widget = spotifyweb.NewWidget(app, pages) case "status": widget = status.NewWidget(app) case "system": widget = system.NewWidget(app, date, version) - case "spotify": - widget = spotify.NewWidget(app, pages) - case "spotifyweb": - widget = spotifyweb.NewWidget(app, pages) case "textfile": widget = textfile.NewWidget(app, pages) case "todo": diff --git a/modules/spotify/settings.go b/modules/spotify/settings.go new file mode 100644 index 00000000..fe81ff57 --- /dev/null +++ b/modules/spotify/settings.go @@ -0,0 +1,18 @@ +package spotify + +import ( + "github.com/olebedev/config" + "github.com/wtfutil/wtf/cfg" +) + +type Settings struct { + common *cfg.Common +} + +func NewSettingsFromYAML(ymlConfig *config.Config) *Settings { + settings := Settings{ + common: cfg.NewCommonSettingsFromYAML(ymlConfig), + } + + return &settings +} diff --git a/modules/spotify/widget.go b/modules/spotify/widget.go index c6b4aadb..98c4668b 100644 --- a/modules/spotify/widget.go +++ b/modules/spotify/widget.go @@ -20,17 +20,21 @@ const HelpText = ` type Widget struct { wtf.HelpfulWidget wtf.TextWidget - spotigopher.SpotifyClient + + settings *Settings spotigopher.Info + spotigopher.SpotifyClient } -func NewWidget(app *tview.Application, pages *tview.Pages) *Widget { +func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget { spotifyClient := spotigopher.NewClient() widget := Widget{ HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText), TextWidget: wtf.NewTextWidget(app, "Spotify", "spotify", true), - SpotifyClient: spotifyClient, + Info: spotigopher.Info{}, + SpotifyClient: spotifyClient, + settings: settings, } widget.HelpfulWidget.SetView(widget.View) widget.TextWidget.RefreshInt = 5