Initial commit

This commit is contained in:
Marcus Carlsson
2016-12-29 15:59:53 +01:00
commit 862b2fc891
5 changed files with 130 additions and 0 deletions

32
main.go Normal file
View File

@ -0,0 +1,32 @@
package main
import (
"fmt"
"github.com/godbus/dbus"
"os"
)
func main() {
conn, err := dbus.SessionBus()
if err != nil {
fmt.Fprintln(os.Stderr, "Failed to connect to session bus:", err)
os.Exit(1)
}
conn.BusObject().Call("org.freedesktop.DBus.AddMatch", 0,
"type='signal',path='/org/xmonad/Log',interface='org.xmonad.Log',member='Update'")
c := make(chan *dbus.Signal, 10)
conn.Signal(c)
for s := range c {
if len(s.Body) == 0 {
continue
}
// Convert the result to a slice of strings
res, ok := s.Body[0].(string)
if !ok {
continue
}
fmt.Println(res)
}
}