File: conn_other.go

package info (click to toggle)
golang-dbus 3-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch, stretch-backports
  • size: 368 kB
  • ctags: 487
  • sloc: sh: 41; makefile: 6
file content (27 lines) | stat: -rw-r--r-- 428 bytes parent folder | download | duplicates (3)
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
// +build !darwin

package dbus

import (
	"bytes"
	"errors"
	"os/exec"
)

func sessionBusPlatform() (*Conn, error) {
	cmd := exec.Command("dbus-launch")
	b, err := cmd.CombinedOutput()

	if err != nil {
		return nil, err
	}

	i := bytes.IndexByte(b, '=')
	j := bytes.IndexByte(b, '\n')

	if i == -1 || j == -1 {
		return nil, errors.New("dbus: couldn't determine address of session bus")
	}

	return Dial(string(b[i+1 : j]))
}