diff --git a/src/go/tsgo/dbus.go b/src/go/tsgo/dbus.go new file mode 100644 index 0000000..f576022 --- /dev/null +++ b/src/go/tsgo/dbus.go @@ -0,0 +1,21 @@ +package tsgo + +import "github.com/godbus/dbus" + +var dbusConn *dbus.Conn + +func initDbus() { + dbusConn, _ = dbus.ConnectSessionBus() + // Add error handling +} + +func notifyPoke(from, message string) { + obj := dbusConn.Object("org.freedesktop.Notifications", "/org/freedesktop/Notifications") + call := obj.Call("org.freedesktop.Notifications.Notify", 0, "teamspeak3", uint32(0), + "", "Poke from "+from, message, []string{}, + map[string]dbus.Variant{"urgency": dbus.MakeVariant(byte(2))}, int32(-1)) + + if call.Err != nil { + // TODO error handleling + } +} diff --git a/src/go/tsgo/tsgo.go b/src/go/tsgo/tsgo.go index c324f2a..c540f3a 100644 --- a/src/go/tsgo/tsgo.go +++ b/src/go/tsgo/tsgo.go @@ -30,6 +30,7 @@ var ( //Ts3pluginInit init plugin function func Ts3pluginInit() int { + initDbus() return 0 } @@ -45,6 +46,8 @@ func Ts3pluginShutdown() { // Ts3onClientPokeEvent event func Ts3onClientPokeEvent(serverConnectionHandlerID uint64, fromClientID AnyId, pokerName string, pokerUniqueIdentity string, message string, ffIgnored int) int { + notifyPoke(pokerName, message) + // TODO add correct color and icon msg := fmt.Sprintf("[color=blue]<%s> [URL=client://%d/%s]\"%s\"[/URL] pokes you", time.Now().Format("15:04:05"), fromClientID, pokerUniqueIdentity, pokerName)