conn_darwin.go 391 B

12345678910111213141516171819202122
  1. package dbus
  2. import (
  3. "errors"
  4. "os/exec"
  5. )
  6. func sessionBusPlatform() (*Conn, error) {
  7. cmd := exec.Command("launchctl", "getenv", "DBUS_LAUNCHD_SESSION_BUS_SOCKET")
  8. b, err := cmd.CombinedOutput()
  9. if err != nil {
  10. return nil, err
  11. }
  12. if len(b) == 0 {
  13. return nil, errors.New("dbus: couldn't determine address of session bus")
  14. }
  15. return Dial("unix:path=" + string(b[:len(b)-1]))
  16. }