From 10058f904a380dc7b9b5ae29400516e927cbe8cc Mon Sep 17 00:00:00 2001 From: Benjamin Reed Date: Tue, 21 Jul 2009 10:33:32 -0400 Subject: [PATCH 3/4] look up DISPLAY from launchd if not initialized --- dbus/dbus-server-launchd.c | 25 ++++++++++++++++++++++++- 1 files changed, 24 insertions(+), 1 deletions(-) diff --git a/dbus/dbus-server-launchd.c b/dbus/dbus-server-launchd.c index 4d26466..3dc9992 100644 --- a/dbus/dbus-server-launchd.c +++ b/dbus/dbus-server-launchd.c @@ -69,9 +69,10 @@ _dbus_server_new_for_launchd (const char *launchd_env_var, DBusError * error) launch_data_t checkin_request; launch_data_t listening_fd_array, listening_fd; launch_data_t environment_dict, environment_param; - const char *launchd_socket_path; + const char *launchd_socket_path, *display; launchd_socket_path = _dbus_getenv (launchd_env_var); + display = _dbus_getenv ("DISPLAY"); _DBUS_ASSERT_ERROR_IS_CLEAR (error); @@ -158,6 +159,28 @@ _dbus_server_new_for_launchd (const char *launchd_env_var, DBusError * error) goto l_failed_0; } + if (display == NULL || *display == '\0') + { + environment_dict = launch_data_dict_lookup (checkin_response, LAUNCH_JOBKEY_USERENVIRONMENTVARIABLES); + if (NULL == environment_dict) + { + _dbus_warn ("Unable to retrieve user environment from launchd."); + } + else + { + environment_param = launch_data_dict_lookup (environment_dict, "DISPLAY"); + if (NULL == environment_dict) + { + _dbus_warn ("Unable to retrieve DISPLAY from launchd."); + } + else + { + display = launch_data_get_string(environment_param); + _dbus_setenv ("DISPLAY", display); + } + } + } + server = _dbus_server_new_for_socket (&launchd_fd, 1, &address); if (server == NULL) { -- 1.6.3.2