Skip to content

Commit

Permalink
feat: notification with sound
Browse files Browse the repository at this point in the history
  • Loading branch information
Крылов Александр committed Jul 12, 2024
1 parent b3c5cef commit 27947a4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ killall go
- CALDAV_SERVER_OFFSET_HOURS default - same as server
- CALDAV_REFRESH_PERIOD_MINUTES default 10
- CALDAV_NOTIFY_BEFORE_MINUTES default 5
- CALDAV_NOTIFY_WITH_SOUND default no. if not empty - sound will be produced

## for better experience
it is useful to create env file with environment variables and source it
3 changes: 3 additions & 0 deletions env.sh.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CALDAV_USERNAME=
CALDAV_PASSWORD=
CALDAV_URL=my.calendar.ru:8080/calendars
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,22 @@ const (
notifyEnvOffset = "CALDAV_SERVER_OFFSET_HOURS"
notifyEnvRefreshPeriod = "CALDAV_REFRESH_PERIOD_MINUTES"
notifyEnvTimeBefore = "CALDAV_NOTIFY_BEFORE_MINUTES"
notifyEnvWithSound = "CALDAV_NOTIFY_WITH_SOUND"
)

func main() {
// TODO delete on first external contribution
notify.Notify("", "https://github.com/Truenya", "notification daemon started", "")
events := make(chan event)
go planEvents(events)

icon := os.Getenv(notifyEnvIcon)
for e := range events {
notify.Notify("", e.Summary, e.Description, icon)
if sound := os.Getenv(notifyEnvWithSound); sound != "" {
notify.Alert("", e.Summary, e.Description, icon)
} else {
notify.Notify("", e.Summary, e.Description, icon)
}
}
}

Expand Down

0 comments on commit 27947a4

Please sign in to comment.