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() {
|
||||
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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue