summaryrefslogtreecommitdiff
path: root/vendor/src/github.com/godbus/dbus/_examples/eavesdrop.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/src/github.com/godbus/dbus/_examples/eavesdrop.go')
-rw-r--r--vendor/src/github.com/godbus/dbus/_examples/eavesdrop.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/vendor/src/github.com/godbus/dbus/_examples/eavesdrop.go b/vendor/src/github.com/godbus/dbus/_examples/eavesdrop.go
new file mode 100644
index 0000000000..11deef3cf8
--- /dev/null
+++ b/vendor/src/github.com/godbus/dbus/_examples/eavesdrop.go
@@ -0,0 +1,30 @@
+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)
+ }
+
+ for _, v := range []string{"method_call", "method_return", "error", "signal"} {
+ call := conn.BusObject().Call("org.freedesktop.DBus.AddMatch", 0,
+ "eavesdrop='true',type='"+v+"'")
+ if call.Err != nil {
+ fmt.Fprintln(os.Stderr, "Failed to add match:", call.Err)
+ os.Exit(1)
+ }
+ }
+ c := make(chan *dbus.Message, 10)
+ conn.Eavesdrop(c)
+ fmt.Println("Listening for everything")
+ for v := range c {
+ fmt.Println(v)
+ }
+}