2016-01-21 04:19:15 +01:00
|
|
|
package dbus
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"os/exec"
|
|
|
|
)
|
|
|
|
|
2016-12-16 12:55:26 +01:00
|
|
|
func getSessionBusPlatformAddress() (string, error) {
|
2016-01-21 04:19:15 +01:00
|
|
|
cmd := exec.Command("launchctl", "getenv", "DBUS_LAUNCHD_SESSION_BUS_SOCKET")
|
|
|
|
b, err := cmd.CombinedOutput()
|
|
|
|
|
|
|
|
if err != nil {
|
2016-12-16 12:55:26 +01:00
|
|
|
return "", err
|
2016-01-21 04:19:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(b) == 0 {
|
2016-12-16 12:55:26 +01:00
|
|
|
return "", errors.New("dbus: couldn't determine address of session bus")
|
2016-01-21 04:19:15 +01:00
|
|
|
}
|
|
|
|
|
2016-12-16 12:55:26 +01:00
|
|
|
return "unix:path=" + string(b[:len(b)-1]), nil
|
2016-01-21 04:19:15 +01:00
|
|
|
}
|