Skip to content
Draft
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
56 changes: 40 additions & 16 deletions modules/gcal/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
}
Expand All @@ -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"
}

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