Skip to content

Commit d33e630

Browse files
committed
feat(notification): add email notification option
- add urgent field to notification config - use beeep.Alert() for urgent notifications - update schema.json and documentation with urgent option
1 parent 622441a commit d33e630

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ work:
123123
# cross-platform notifications
124124
notification:
125125
enabled: true
126+
urgent: true # persistent notification with alert sound (platform-dependent)
126127
title: work finished 🎉
127128
message: time to take a break
128129
icon: ~/my/icon.png

cmd/runner.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,13 @@ func sendNotification(notification config.Notification) {
163163
icon = notification.Icon
164164
}
165165

166-
err := beeep.Notify(notification.Title, notification.Message, icon)
166+
var err error
167+
if notification.Urgent {
168+
err = beeep.Alert(notification.Title, notification.Message, icon)
169+
} else {
170+
err = beeep.Notify(notification.Title, notification.Message, icon)
171+
}
172+
167173
if err != nil {
168174
log.Println("failed to send notification:", err)
169175
}
@@ -204,7 +210,6 @@ func printSummary() {
204210
fmt.Println(" Total:", totalWorkDuration+totalBreakDuration)
205211
}
206212

207-
// progress bar
208213
totalDuration := totalWorkDuration + totalBreakDuration
209214
workRatio := float64(totalWorkDuration.Milliseconds()) / float64(totalDuration.Milliseconds())
210215

config/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const (
2525

2626
type Notification struct {
2727
Enabled bool
28+
Urgent bool
2829
Title string
2930
Message string
3031
Icon string
@@ -67,6 +68,7 @@ var (
6768
"title": "work session",
6869
"notification": map[string]any{
6970
"enabled": true,
71+
"urgent": false,
7072
"title": "work finished 🎉",
7173
"message": "time to take a break!",
7274
},
@@ -76,6 +78,7 @@ var (
7678
"title": "break session",
7779
"notification": map[string]any{
7880
"enabled": true,
81+
"urgent": false,
7982
"title": "break over 😴",
8083
"message": "back to work!",
8184
},

config/schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@
9191
"description": "Enable desktop notifications",
9292
"default": true
9393
},
94+
"urgent": {
95+
"type": "boolean",
96+
"description": "Mark notification as urgent",
97+
"default": false
98+
},
9499
"title": {
95100
"type": "string",
96101
"description": "Notification title text",

pomo.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ work:
1414
title: work session
1515
notification:
1616
enabled: true
17+
urgent: false
1718
title: work finished 🎉
1819
message: time to take a break
1920
# icon: ~/path/to/icon.png
@@ -25,6 +26,7 @@ break:
2526
title: break session
2627
notification:
2728
enabled: true
29+
urgent: false
2830
title: break over 😴
2931
message: back to work!
3032
# icon: C:\Users\path\to\your\icon.png

0 commit comments

Comments
 (0)