aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-09-15 13:49:33 +0200
committerDanilo M. <danix@danix.xyz>2026-09-15 13:49:33 +0200
commitc3c33008bc0aae4971d854e6edcd48144d593bfb (patch)
tree0680ae3dec032dd4ccd5267e2abc92e3e08a41af /cmd
parentdbecac7041605a5dc8dd88109f71ea00a5692faa (diff)
downloadnotifyd-c3c33008bc0aae4971d854e6edcd48144d593bfb.tar.gz
notifyd-c3c33008bc0aae4971d854e6edcd48144d593bfb.zip
feat: add the D-Bus service and the daemon
Notify assigns an id and publishes; a replaces_id or stack tag reuses the id. CloseNotification closes with reason 3. The daemon claims org.freedesktop.Notifications and exits non-zero if it cannot, which is what happens while dunst still holds it.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/notifyd/main.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/cmd/notifyd/main.go b/cmd/notifyd/main.go
new file mode 100644
index 0000000..f6d2b12
--- /dev/null
+++ b/cmd/notifyd/main.go
@@ -0,0 +1,39 @@
+// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as
+// published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+package main
+
+import (
+ "log"
+
+ "danix.xyz/notifyd/internal/notify"
+ "github.com/godbus/dbus/v5"
+)
+
+func main() {
+ conn, err := dbus.SessionBus()
+ if err != nil {
+ log.Fatalf("notifyd: session bus: %v", err)
+ }
+ reply, err := conn.RequestName(notify.Name, dbus.NameFlagDoNotQueue)
+ if err != nil {
+ log.Fatalf("notifyd: request %s: %v", notify.Name, err)
+ }
+ if reply != dbus.RequestNameReplyPrimaryOwner {
+ log.Fatalf("notifyd: %s is already owned (is dunst running?)", notify.Name)
+ }
+ svc := notify.NewService(conn, notify.RuntimeDir())
+ if err := svc.Start(); err != nil {
+ log.Fatalf("notifyd: %v", err)
+ }
+ log.Printf("notifyd: listening on %s", notify.Name)
+ select {}
+}