implemented dbus notify

This commit is contained in:
Niklas 2020-09-09 22:52:29 +02:00
parent 3947cfcce2
commit 42d5dec6d9
2 changed files with 24 additions and 0 deletions

21
src/go/tsgo/dbus.go Normal file
View File

@ -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
}
}

View File

@ -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)