diff --git a/modules/gcal/display.go b/modules/gcal/display.go index 26d5344b..81aff3f7 100644 --- a/modules/gcal/display.go +++ b/modules/gcal/display.go @@ -171,7 +171,7 @@ func (widget *Widget) timeUntil(calEvent *CalEvent) string { func (widget *Widget) titleColor(calEvent *CalEvent) string { color := widget.settings.colors.title - for _, untypedArr := range widget.settings.highlights { + for _, untypedArr := range widget.settings.colors.highlights { highlightElements := utils.ToStrs(untypedArr.([]interface{})) match, _ := regexp.MatchString( diff --git a/modules/gcal/settings.go b/modules/gcal/settings.go index 79943150..ca8e1127 100644 --- a/modules/gcal/settings.go +++ b/modules/gcal/settings.go @@ -16,6 +16,7 @@ type colors struct { highlights []interface{} `help:"A list of arrays that define a regular expression pattern and a color. If a calendar event title matches a regular expression, the title will be drawn in that colour. Over-rides the default title colour." values:"An array of a valid regular expression, any X11 color name." optional:"true"` } +// Settings defines the configuration options for this module type Settings struct { colors common *cfg.Common @@ -26,13 +27,14 @@ type Settings struct { email string `help:"The email address associated with your Google account. Necessary for determining 'responseStatus'." values:"A valid email address string."` eventCount int `help:"The number of calendar events to display." values:"A positive integer, 0..n." optional:"true"` multiCalendar bool `help:"Whether or not to display your primary calendar or all calendars you have access to." values:"true or false" optional:"true"` - secretFile string `help:"Your Google client secret JSON file." values:"A string representing a file path to the JSON secret file."` - showDeclined bool `help:"Whether or not to display events you’ve declined to attend." values:"true or false" optional:"true"` - withLocation bool `help:"Whether or not to show the location of the appointment." values:"true or false"` - timezone string `help:"The time zone used to display calendar event times." values:"A valid TZ database time zone string" optional:"true"` - calendarReadLevel string `help:"The calender read level specifies level you want to read events. Default: writer " values:"reader, writer", optional: "true"` + secretFile string `help:"Your Google client secret JSON file." values:"A string representing a file path to the JSON secret file."` + showDeclined bool `help:"Whether or not to display events you’ve declined to attend." values:"true or false" optional:"true"` + withLocation bool `help:"Whether or not to show the location of the appointment." values:"true or false"` + timezone string `help:"The time zone used to display calendar event times." values:"A valid TZ database time zone string" optional:"true"` + calendarReadLevel string `help:"The calender read level specifies level you want to read events. Default: writer " values:"reader, writer" optional:"true"` } +// NewSettingsFromYAML creates and returns an instance of Settings with configuration options populated func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings { settings := Settings{ @@ -53,6 +55,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co settings.colors.day = ymlConfig.UString("colors.day", "forestgreen") settings.colors.description = ymlConfig.UString("colors.description", "white") + settings.colors.highlights = ymlConfig.UList("colors.highlights") settings.colors.past = ymlConfig.UString("colors.past", "gray") settings.colors.title = ymlConfig.UString("colors.title", "white")