File: README.markdown

package info (click to toggle)
golang-go-dbus 1~bzr20150122-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 328 kB
  • sloc: makefile: 13
file content (57 lines) | stat: -rw-r--r-- 1,422 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Documentation
=============

Look at the API on [GoPkgDoc](http://gopkgdoc.appspot.com/pkg/github.com/norisatir/go-dbus).

Installation
============

    go get launchpad.net/go-dbus/v1

Usage
=====

An example
----------

```go
// Issue OSD notifications according to the Desktop Notifications Specification 1.1
//      http://people.canonical.com/~agateau/notifications-1.1/spec/index.html
// See also
//      https://wiki.ubuntu.com/NotifyOSD#org.freedesktop.Notifications.Notify
package main

import "launchpad.net/go-dbus/v1"
import "log"

func main() {
    var (
        err error
        conn *dbus.Connection
    )

    // Connect to Session or System buses.
    if conn, err = dbus.Connect(dbus.SessionBus); err != nil {
        log.Fatal("Connection error:", err)
    }

    // Create an object proxy
    obj := conn.Object("org.freedesktop.Notifications", "/org/freedesktop/Notifications")

    // Call object methods.
    reply, err := obj.Call("org.freedesktop.Notifications", "Notify",
        "dbus-tutorial", uint32(0), "",
        "dbus-tutorial", "You've been notified!",
	[]string{}, map[string]dbus.Variant{}, int32(-1))
    if err != nil {
        log.Fatal("Notification error:", err)
    }

    // Parse the reply message
    var notification_id uint32
    if err := reply.GetArgs(&notification_id); err != nil {
        log.Fatal(err)
    }
    log.Print("Notification id:", notification_id)
}
```