--- gio/gdbusaddress.c.orig 2020-10-01 07:43:53.000000000 -0500 +++ gio/gdbusaddress.c 2021-12-15 18:20:06.000000000 -0600 @@ -1223,6 +1223,103 @@ /* ---------------------------------------------------------------------------------------------------- */ +/* + * MacPorts specific D-Bus implementation + * + * When building under MacPorts on darwin + * plaforms (including Mac OS X), the + * symbols G_OS_UNIX and __APPLE__ are + * asserted. + * + * The D-Bus session daemon is controlled + * using the Apple launchd facility. + * + * For launchd command details see + * http://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages + * + * launchd(8) + * launchctl(1) + * launchd.plist(5) + */ + +#if defined (G_OS_UNIX) && defined (__APPLE__) +static gchar * +get_session_address_macports_specific (GError **error) +{ + gchar *ret; + gchar *command_line; + gchar *launchctl_stdout; + gchar *launchctl_stderr; + gint exit_status; + + ret = NULL; + command_line = NULL; + launchctl_stdout = NULL; + launchctl_stderr = NULL; + + command_line = g_strdup ("launchctl getenv DBUS_LAUNCHD_SESSION_BUS_SOCKET"); + + if (G_UNLIKELY (_g_dbus_debug_address ())) + { + _g_dbus_debug_print_lock (); + g_print ("GDBus-debug:Address: launchctl command line: `%s'\n", command_line); + _g_dbus_debug_print_unlock (); + } + + if (g_spawn_command_line_sync (command_line, + &launchctl_stdout, + &launchctl_stderr, + &exit_status, + error)) + { + if (g_spawn_check_exit_status (exit_status, error)) + { + if (launchctl_stdout != NULL) + { + if (G_UNLIKELY (_g_dbus_debug_address ())) + { + gchar *s; + _g_dbus_debug_print_lock (); + g_print ("GDBus-debug:Address: launchctl stdout:"); + s = _g_dbus_hexdump (launchctl_stdout, strlen (launchctl_stdout) + 1, 2); + g_print ("\n%s", s); + g_free (s); + _g_dbus_debug_print_unlock (); + } + + if (*launchctl_stdout != '\0') + { + gchar *lastchar; + + lastchar = launchctl_stdout + strlen(launchctl_stdout) - 1; + if (*lastchar == '\n') *lastchar = '\0'; + ret = g_strdup_printf ("unix:path=%s", launchctl_stdout); + } + else + { + g_set_error (error, + G_IO_ERROR, + G_IO_ERROR_FAILED, + _("Session D-Bus not running. Try running `launchctl load -w /Library/LaunchAgents/org.freedesktop.dbus-session.plist'.")); + } + } + } + else + { + g_prefix_error (error, _("Error spawning command line `%s': "), command_line); + } + } + + g_free (command_line); + g_free (launchctl_stdout); + g_free (launchctl_stderr); + + return ret; +} +#endif + +/* ---------------------------------------------------------------------------------------------------- */ + static gchar * get_session_address_platform_specific (GError **error) { @@ -1251,7 +1348,12 @@ * X11 autolaunching; on Windows this means a different autolaunching * mechanism based on shared memory. */ + +#ifdef __APPLE__ + return get_session_address_macports_specific (error); +#else return get_session_address_dbus_launch (error); +#endif } /* ---------------------------------------------------------------------------------------------------- */ --- gio/gdbusaddress.c.orig 2023-05-13 13:21:23.000000000 -0400 +++ gio/gdbusaddress.c 2023-05-13 13:21:55.000000000 -0400 @@ -1444,7 +1444,7 @@ * https://dbus.freedesktop.org/doc/dbus-specification.html#ftn.id-1.13.6.4.3.3 * or, on systems where /run is the same as /var/run, runstatedir: * https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/209 */ - ret = g_strdup ("unix:path=" GLIB_RUNSTATEDIR "/dbus/system_bus_socket"); + ret = g_strdup ("unix:path=@PREFIX@/var/run/dbus/system_bus_socket"); } break;