Skip to content

Commit

Permalink
Improve notify API on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
qianlifeng committed Oct 28, 2024
1 parent 963d762 commit dce4389
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 162 deletions.
150 changes: 0 additions & 150 deletions Wox/util/notifier/notify_linux.c

This file was deleted.

26 changes: 14 additions & 12 deletions Wox/util/notifier/notify_linux.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
package notifier

/*
#cgo pkg-config: cairo
#cgo LDFLAGS: -lX11
#include <stdlib.h>
void showNotification(const char* message);
*/
import "C"
import "unsafe"
import (
"github.com/godbus/dbus/v5"
)

func ShowNotification(message string) {
cMessage := C.CString(message)
defer C.free(unsafe.Pointer(cMessage))
conn, err := dbus.SessionBus()
if err != nil {
return
}
defer conn.Close()

C.showNotification(cMessage)
obj := conn.Object("org.freedesktop.Notifications", "/org/freedesktop/Notifications")
call := obj.Call("org.freedesktop.Notifications.Notify", 0, "Wox", uint32(0),
"", "Wox", message, []string{}, map[string]dbus.Variant{}, int32(5000))
if call.Err != nil {
return
}
}

0 comments on commit dce4389

Please sign in to comment.