diff --git a/modules/gcal/display.go b/modules/gcal/display.go index 684fa94c2..076cd2b4e 100644 --- a/modules/gcal/display.go +++ b/modules/gcal/display.go @@ -38,7 +38,7 @@ func (widget *Widget) content() (string, string, bool) { } ts := calEvent.Timestamp(widget.settings.hourFormat, widget.settings.showEndTime) - timestamp := fmt.Sprintf("[%s]%s", widget.eventTimeColor(), ts) + timestamp := fmt.Sprintf("[%s]%s ", widget.eventTimeColor(), ts) if calEvent.AllDay() { timestamp = "" } @@ -48,21 +48,41 @@ func (widget *Widget) content() (string, string, bool) { widget.eventSummary(calEvent, calEvent.ConflictsWith(calEvents)), ) - lineOne := fmt.Sprintf( - "%s %s %s %s[white]\n", - widget.dayDivider(calEvent, prevEvent), - widget.responseIcon(calEvent), - timestamp, - eventTitle, - ) - - str += fmt.Sprintf("%s %s%s\n", - lineOne, - widget.location(calEvent), - widget.timeUntil(calEvent), - ) + var lineOne string + if widget.settings.compact { + lineOne = fmt.Sprintf( + "%s %s %s%s[white]", + widget.dayDivider(calEvent, prevEvent), + widget.responseIcon(calEvent), + timestamp, + eventTitle, + ) + str += fmt.Sprintf("%s %s\n", + lineOne, + widget.timeUntil(calEvent), + ) + + location := widget.location(calEvent) + if location != "" { + str += location + "\n" + } + } else { + lineOne = fmt.Sprintf( + "%s %s %s%s[white]\n", + widget.dayDivider(calEvent, prevEvent), + widget.responseIcon(calEvent), + timestamp, + eventTitle, + ) + + str += fmt.Sprintf("%s %s%s\n", + lineOne, + widget.location(calEvent), + widget.timeUntil(calEvent), + ) + } - if (widget.location(calEvent) != "") || (widget.timeUntil(calEvent) != "") { + if !widget.settings.compact && ((widget.location(calEvent) != "") || (widget.timeUntil(calEvent) != "")) { str += "\n" } @@ -159,7 +179,11 @@ func (widget *Widget) timeUntil(calEvent *CalEvent) string { } } - return color + untilStr + "[white]" + if widget.settings.compact { + return fmt.Sprintf("%s[%s][white]", color, untilStr) + } else { + return color + untilStr + "[white]" + } } func (widget *Widget) titleColor(calEvent *CalEvent) string { diff --git a/modules/gcal/settings.go b/modules/gcal/settings.go index 5c1c9ace7..5fa191729 100644 --- a/modules/gcal/settings.go +++ b/modules/gcal/settings.go @@ -39,6 +39,7 @@ type Settings struct { 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"` + compact bool `help:"Whether to display compact view" values:"true or false" optional:"true" default:"false"` } // NewSettingsFromYAML creates and returns an instance of Settings with configuration options populated @@ -60,6 +61,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co withLocation: ymlConfig.UBool("withLocation", true), timezone: ymlConfig.UString("timezone", ""), calendarReadLevel: ymlConfig.UString("calendarReadLevel", "writer"), + compact: ymlConfig.UBool("compact", false), } settings.day = ymlConfig.UString("colors.day", settings.Colors.Subheading)