refactor: separate dbus functions from internal
This commit is contained in:
parent
549b520a4c
commit
1c1160eb00
21
main.go
21
main.go
|
|
@ -58,29 +58,30 @@ func (s notificationServer) Notify(appName string,
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
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 := sync.WaitGroup{}
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go s.CloseNotification(n.ReplacesId)
|
go clearNotification(n.ReplacesId, n.ExpireTimeout)
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
//const ClearLine = "\033[2K"
|
|
||||||
//fmt.Printf(ClearLine)
|
|
||||||
//fmt.Printf("\r")
|
|
||||||
fmt.Printf("%s\n", res)
|
fmt.Printf("%s\n", res)
|
||||||
return 0, nil
|
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)
|
log.Println("close the notification", id)
|
||||||
fmt.Printf("\n")
|
fmt.Printf("\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s notificationServer) CloseNotification(id uint32) {
|
||||||
|
log.Println("dbus called CloseNotification", id)
|
||||||
|
}
|
||||||
|
|
||||||
func (s notificationServer) GetCapabilities() ([]string, *dbus.Error) {
|
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
|
return []string{"action-icons", "actions", "body", "body-hyperlinks", "body-images", "body-markup", "icon-multi", "icon-static", "persistence", "sound"}, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue