implemented dbus notify
This commit is contained in:
parent
3947cfcce2
commit
42d5dec6d9
21
src/go/tsgo/dbus.go
Normal file
21
src/go/tsgo/dbus.go
Normal 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
|
||||
}
|
||||
}
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user