conn_darwin.go (767B)
1 package dbus 2 3 import ( 4 "errors" 5 "fmt" 6 "os" 7 "os/exec" 8 ) 9 10 const defaultSystemBusAddress = "unix:path=/opt/local/var/run/dbus/system_bus_socket" 11 12 func getSessionBusPlatformAddress() (string, error) { 13 cmd := exec.Command("launchctl", "getenv", "DBUS_LAUNCHD_SESSION_BUS_SOCKET") 14 b, err := cmd.CombinedOutput() 15 16 if err != nil { 17 return "", err 18 } 19 20 if len(b) == 0 { 21 return "", errors.New("dbus: couldn't determine address of session bus") 22 } 23 24 return "unix:path=" + string(b[:len(b)-1]), nil 25 } 26 27 func getSystemBusPlatformAddress() string { 28 address := os.Getenv("DBUS_LAUNCHD_SESSION_BUS_SOCKET") 29 if address != "" { 30 return fmt.Sprintf("unix:path=%s", address) 31 } 32 return defaultSystemBusAddress 33 } 34 35 func tryDiscoverDbusSessionBusAddress() string { 36 return "" 37 }