Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add colors.eventTime to gcal #640

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion modules/gcal/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
}
Expand Down Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions modules/gcal/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`

Expand Down Expand Up @@ -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")
Expand Down