From 1c1160eb00ab527f7dff3a9c79c9335289a9fdd2496740dbcc9014bbfb1df6f1 Mon Sep 17 00:00:00 2001 From: Viktor Varland Date: Thu, 3 Apr 2025 09:48:29 +0200 Subject: [PATCH] refactor: separate dbus functions from internal --- main.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/main.go b/main.go index cdbf9f8..0dc3d03 100644 --- a/main.go +++ b/main.go @@ -58,29 +58,30 @@ func (s notificationServer) Notify(appName string, } defer func() { - timeout, err := time.ParseDuration(fmt.Sprintf("%vms", n.ExpireTimeout)) - if n.ExpireTimeout == -1 || err != nil { - timeout = time.Duration(5000 * time.Millisecond) - } - time.Sleep(timeout) wg := sync.WaitGroup{} wg.Add(1) - go s.CloseNotification(n.ReplacesId) + go clearNotification(n.ReplacesId, n.ExpireTimeout) wg.Done() }() - //const ClearLine = "\033[2K" - //fmt.Printf(ClearLine) - //fmt.Printf("\r") fmt.Printf("%s\n", res) return 0, nil } -func (s notificationServer) CloseNotification(id uint32) { +func clearNotification(id uint32, t int32) { + timeout, err := time.ParseDuration(fmt.Sprintf("%vms", t)) + if t == -1 || err != nil { + timeout = time.Duration(5000 * time.Millisecond) + } + time.Sleep(timeout) log.Println("close the notification", id) fmt.Printf("\n") } +func (s notificationServer) CloseNotification(id uint32) { + log.Println("dbus called CloseNotification", id) +} + func (s notificationServer) GetCapabilities() ([]string, *dbus.Error) { return []string{"action-icons", "actions", "body", "body-hyperlinks", "body-images", "body-markup", "icon-multi", "icon-static", "persistence", "sound"}, nil }