From 1ce29f4930682a4cabf3b1e39a616b8b5ed3fad1 Mon Sep 17 00:00:00 2001 From: Indradhanush Gupta Date: Wed, 18 Sep 2019 01:21:29 +0530 Subject: [PATCH 1/2] modules/gcal: Add property colors.eventTime This will let the user set a fixed color for the event time irrespective of colors used in highlights. --- modules/gcal/settings.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/gcal/settings.go b/modules/gcal/settings.go index ca8e1127..f702e4f5 100644 --- a/modules/gcal/settings.go +++ b/modules/gcal/settings.go @@ -10,6 +10,7 @@ const defaultTitle = "Calendar" type colors struct { day string description string `help:"The default color for calendar event descriptions." values:"Any X11 color name." optional:"true"` + eventTime string `help:"The default color for calendar event times." values:"Any X11 color name." optional:"true"` past string `help:"The color for calendar events that have passed." values:"Any X11 color name." optional:"true"` title string `help:"The default colour for calendar event titles." values:"Any X11 color name." optional:"true"` @@ -55,6 +56,14 @@ 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.eventTime is a new feature introduced via issue #638. Prior to this, the color of the event + // time was (unintentionally) customized via settings.colors.description. To maintain backwards compatibility + // for users who might be already using this to set the color of the event time, we try to determine the default + // from settings.colors.description. If it is not set, then the default value of "white" is used. Finally, if a + // user sets a value for colors.eventTime, it overrides the defaults. + // + // PS: We should have a deprecation plan for supporting this backwards compatibility feature. + settings.colors.eventTime = ymlConfig.UString("colors.eventTime", settings.colors.description) settings.colors.highlights = ymlConfig.UList("colors.highlights") settings.colors.past = ymlConfig.UString("colors.past", "gray") settings.colors.title = ymlConfig.UString("colors.title", "white") From 9e2bc00b1556d63d1671ea91ca2c1ea2fa41ad08 Mon Sep 17 00:00:00 2001 From: Indradhanush Gupta Date: Wed, 18 Sep 2019 01:23:27 +0530 Subject: [PATCH 2/2] modules/gcal: Use colors.eventTime for timestamp of event Color of description should not change the color of event time. This commit uses the independent setting color.eventTime instead. This defaults to "white" and is consistent with the current behaviour when a value for colors.description is not set. Fixes #638 --- modules/gcal/display.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/gcal/display.go b/modules/gcal/display.go index 81aff3f7..57e7b63d 100644 --- a/modules/gcal/display.go +++ b/modules/gcal/display.go @@ -48,7 +48,7 @@ func (widget *Widget) content() (string, string, bool) { } for _, calEvent := range calEvents { - timestamp := fmt.Sprintf("[%s]%s", widget.descriptionColor(calEvent), calEvent.Timestamp()) + timestamp := fmt.Sprintf("[%s]%s", widget.eventTimeColor(calEvent), calEvent.Timestamp()) if calEvent.AllDay() { timestamp = "" } @@ -116,6 +116,10 @@ func (widget *Widget) descriptionColor(calEvent *CalEvent) string { return widget.settings.colors.description } +func (widget *Widget) eventTimeColor(calEvent *CalEvent) string { + return widget.settings.colors.eventTime +} + func (widget *Widget) eventSummary(calEvent *CalEvent, conflict bool) string { summary := calEvent.event.Summary