Skip to content

Commit 8ae0f4a

Browse files
committed
Resolve conflict and fixes according to linter
1 parent ef337ae commit 8ae0f4a

2 files changed

Lines changed: 11 additions & 16 deletions

File tree

decks/main.deck

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,6 @@
6060
[keys.action_hold]
6161
keycode = "Mute"
6262

63-
[[keys]]
64-
index = 7
65-
[keys.widget]
66-
id = "timer"
67-
[keys.widget.config]
68-
times = "5s;10m;30m;1h5m" # optional
69-
format = "%Hh;%Im;%Ss"
70-
font = "bold;regular;thin" # optional
71-
#color = "#fefefe" # optional
72-
underflow = "false" # optional
73-
underflowColor = "#ff0000;#ff0000;#ff0000" # optional
74-
75-
7663
[[keys]]
7764
index = 8
7865
[keys.widget]

widget_timer.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"time"
88
)
99

10-
// TimerWidget is a widget displaying a timer
10+
// TimerWidget is a widget displaying a timer.
1111
type TimerWidget struct {
1212
*BaseWidget
1313

@@ -26,29 +26,34 @@ type TimerWidget struct {
2626
data TimerData
2727
}
2828

29+
// TimerData represents the current state of the timer.
2930
type TimerData struct {
3031
startTime time.Time
3132
pausedTime time.Time
3233
}
3334

35+
// IsPaused returns whether the timer is paused.
3436
func (d *TimerData) IsPaused() bool {
3537
return !d.pausedTime.IsZero()
3638
}
3739

40+
// IsRunning returns whether the timer is running.
3841
func (d *TimerData) IsRunning() bool {
3942
return !d.IsPaused() && d.HasDeadline()
4043
}
4144

45+
// HasDeadline returns whether the start time is set.
4246
func (d *TimerData) HasDeadline() bool {
4347
return !d.startTime.IsZero()
4448
}
4549

50+
// Clear resets the state of the timer.
4651
func (d *TimerData) Clear() {
4752
d.startTime = time.Time{}
4853
d.pausedTime = time.Time{}
4954
}
5055

51-
// NewTimerWidget returns a new TimerWidget
56+
// NewTimerWidget returns a new TimerWidget.
5257
func NewTimerWidget(bw *BaseWidget, opts WidgetConfig) *TimerWidget {
5358
bw.setInterval(time.Duration(opts.Interval)*time.Millisecond, time.Second/2)
5459

@@ -149,6 +154,7 @@ func (w *TimerWidget) Update() error {
149154

150155
type Timespan time.Duration
151156

157+
// Format returns the formatted version of the timespan.
152158
func (t Timespan) Format(format string, adaptive bool) string {
153159
formatStr := format
154160
tm := map[string]string{
@@ -193,13 +199,15 @@ func (t Timespan) Format(format string, adaptive bool) string {
193199
return timeStr
194200
}
195201

202+
// ReplaceAll does a replacement with all entries of a map.
196203
func ReplaceAll(str string, tm map[string]string) string {
197204
for k, v := range tm {
198205
str = strings.ReplaceAll(str, k, v)
199206
}
200207
return str
201208
}
202209

210+
// TriggerAction updates the timer state.
203211
func (w *TimerWidget) TriggerAction(hold bool) {
204212
if hold {
205213
if w.data.IsPaused() {
@@ -211,7 +219,7 @@ func (w *TimerWidget) TriggerAction(hold bool) {
211219
if w.data.IsRunning() {
212220
w.data.pausedTime = time.Now()
213221
} else if w.data.IsPaused() && w.data.HasDeadline() {
214-
pausedDuration := time.Now().Sub(w.data.pausedTime)
222+
pausedDuration := time.Since(w.data.pausedTime)
215223
w.data.startTime = w.data.startTime.Add(pausedDuration)
216224
w.data.pausedTime = time.Time{}
217225
} else {

0 commit comments

Comments
 (0)