diff --git a/gcal/widget.go b/gcal/widget.go index 2a8e345d..8baf3422 100644 --- a/gcal/widget.go +++ b/gcal/widget.go @@ -60,17 +60,41 @@ func (widget *Widget) addView() { func (widget *Widget) contentFrom(events *calendar.Events) string { str := "\n" - for _, item := range events.Items { - startTime, _ := time.Parse(time.RFC3339, item.Start.DateTime) + for _, event := range events.Items { + startTime, _ := time.Parse(time.RFC3339, event.Start.DateTime) timestamp := startTime.Format("Mon, Jan 2, 15:04") until := widget.until(startTime) - str = str + fmt.Sprintf(" [%s]%s[white]\n [%s]%s %s[white]\n\n", titleColor(item), item.Summary, descriptionColor(item), timestamp, until) + summary := event.Summary + if widget.eventIsNow(event) { + summary = "ðŸ”Ĩ " + summary + } + + str = str + fmt.Sprintf(" [%s]%s[white]\n [%s]%s %s[white]\n\n", titleColor(event), summary, descriptionColor(event), timestamp, until) } return str } +// eventIsNow returns true if the event is happening now, false if it not +func (widget *Widget) eventIsNow(event *calendar.Event) bool { + startTime, _ := time.Parse(time.RFC3339, event.Start.DateTime) + endTime, _ := time.Parse(time.RFC3339, event.End.DateTime) + + return time.Now().After(startTime) && time.Now().Before(endTime) +} + +func descriptionColor(item *calendar.Event) string { + ts, _ := time.Parse(time.RFC3339, item.Start.DateTime) + + color := "white" + if ts.Before(time.Now()) { + color = "grey" + } + + return color +} + func titleColor(item *calendar.Event) string { ts, _ := time.Parse(time.RFC3339, item.Start.DateTime) @@ -86,17 +110,6 @@ func titleColor(item *calendar.Event) string { return color } -func descriptionColor(item *calendar.Event) string { - ts, _ := time.Parse(time.RFC3339, item.Start.DateTime) - - color := "white" - if ts.Before(time.Now()) { - color = "grey" - } - - return color -} - // until returns the number of hours or days until the event // If the event is in the past, returns nil func (widget *Widget) until(start time.Time) string { diff --git a/security/widget.go b/security/widget.go index c4d1ac3e..b983ab84 100644 --- a/security/widget.go +++ b/security/widget.go @@ -35,7 +35,7 @@ func NewWidget() *Widget { func (widget *Widget) Refresh() { data := Fetch() - widget.View.SetTitle(" ðŸĶ‚ Security ") + widget.View.SetTitle(" ðŸĪš Security ") widget.RefreshedAt = time.Now() widget.View.Clear() diff --git a/status/widget.go b/status/widget.go index 8fd28350..7b99d909 100644 --- a/status/widget.go +++ b/status/widget.go @@ -55,7 +55,7 @@ func (widget *Widget) addView() { } func (widget *Widget) contentFrom() string { - icons := []string{"👍", "ðŸĪœ", "ðŸĪ™", "ðŸĪœ"} + icons := []string{"👍", "ðŸĪœ", "ðŸĪ™", "ðŸĪœ", "ðŸĪ˜", "ðŸĪœ", "✊", "ðŸĪœ", "👌", "ðŸĪœ"} next := icons[widget.Current] widget.Current = widget.Current + 1