From e487f8a50bddd4de20a79532b0f940b8a0177e43 Mon Sep 17 00:00:00 2001 From: Benjamin Reed Date: Tue, 21 Jul 2009 10:33:32 -0400 Subject: [PATCH 3/7] 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 bcfb558..52782aa 100644 --- a/dbus/dbus-server-launchd.c +++ b/dbus/dbus-server-launchd.c @@ -71,9 +71,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) { _DBUS_ASSERT_ERROR_IS_SET (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_param) + { + _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); -- 1.6.3.2