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

Merge pull request #677 from Tardog/spotify-theming

Support theming for Spotify widget
This commit is contained in:
Chris Cummer 2019-10-04 07:33:54 -07:00 committed by GitHub
commit 07ed1ea60e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 4 deletions

View File

@ -10,7 +10,13 @@ const (
defaultTitle = "Spotify"
)
type colors struct {
label string
text string
}
type Settings struct {
colors
common *cfg.Common
}
@ -19,5 +25,8 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
}
settings.colors.label = ymlConfig.UString("colors.label", "green")
settings.colors.text = ymlConfig.UString("colors.text", "white")
return &settings
}

View File

@ -64,10 +64,13 @@ func (w *Widget) createOutput() (string, string, bool) {
if err != nil {
content = err.Error()
} else {
content = utils.CenterText(fmt.Sprintf("[green]Now %v [white]\n", w.Info.Status), w.CommonSettings().Width)
content += utils.CenterText(fmt.Sprintf("[green]Title:[white] %v\n ", w.Info.Title), w.CommonSettings().Width)
content += utils.CenterText(fmt.Sprintf("[green]Artist:[white] %v\n", w.Info.Artist), w.CommonSettings().Width)
content += utils.CenterText(fmt.Sprintf("[green]%v:[white] %v\n", w.Info.TrackNumber, w.Info.Album), w.CommonSettings().Width)
labelColor := w.settings.colors.label
textColor := w.settings.colors.text
content = utils.CenterText(fmt.Sprintf("[%s]Now %v [%s]\n", labelColor, w.Info.Status, textColor), w.CommonSettings().Width)
content += utils.CenterText(fmt.Sprintf("[%s]Title:[%s] %v\n ", labelColor, textColor, w.Info.Title), w.CommonSettings().Width)
content += utils.CenterText(fmt.Sprintf("[%s]Artist:[%s] %v\n", labelColor, textColor, w.Info.Artist), w.CommonSettings().Width)
content += utils.CenterText(fmt.Sprintf("[%s]%v:[%s] %v\n", labelColor, w.Info.TrackNumber, textColor, w.Info.Album), w.CommonSettings().Width)
}
return w.CommonSettings().Title, content, true
}