diff options
| author | Sean Davis <smd.seandavis@gmail.com> | 2016-08-16 21:33:15 -0400 |
|---|---|---|
| committer | Sean Davis <smd.seandavis@gmail.com> | 2016-08-16 21:33:15 -0400 |
| commit | f016e39ba009e3cfa66c82af9394cae7951e6916 (patch) | |
| tree | 566b58734dd648eb24c3b4ada9f025b03c39fd2d | |
| parent | a4694404c6c439fbfb8192d85589f0fe2b96fb19 (diff) | |
| download | exo-f016e39ba009e3cfa66c82af9394cae7951e6916.tar.gz | |
Correctly import user env
| -rw-r--r-- | exo-helper/exo-helper.c | 20 | ||||
| -rw-r--r-- | exo/exo-execute.c | 21 |
2 files changed, 29 insertions, 12 deletions
diff --git a/exo-helper/exo-helper.c b/exo-helper/exo-helper.c index ce5ef9e..14c941d 100644 --- a/exo-helper/exo-helper.c +++ b/exo-helper/exo-helper.c @@ -325,7 +325,12 @@ exo_helper_get_command (const ExoHelper *helper) return *helper->commands_with_parameter; } - +/* Set the DISPLAY variable, to be use by g_spawn_async. */ +static void +set_environment (gchar *display) +{ + g_setenv ("DISPLAY", display, TRUE); +} /** * exo_helper_execute: @@ -352,7 +357,6 @@ exo_helper_execute (ExoHelper *helper, GError *err = NULL; gchar **commands; gchar **argv; - gchar **envp; gchar *command; gchar *display; guint n; @@ -401,16 +405,20 @@ exo_helper_execute (ExoHelper *helper, continue; /* set the display variable */ - envp = g_get_environ (); display = gdk_screen_make_display_name (screen); - envp = g_environ_setenv (envp, "DISPLAY", display, TRUE); /* try to run the command */ - succeed = g_spawn_async (NULL, argv, envp, G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH, NULL, NULL, &pid, &err); + succeed = g_spawn_async (NULL, + argv, + NULL, + G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH, + (GSpawnChildSetupFunc) set_environment, + display, + &pid, + &err); /* cleanup */ g_strfreev (argv); - g_strfreev (envp); g_free (display); /* check if the execution was successful */ diff --git a/exo/exo-execute.c b/exo/exo-execute.c index 1fabf57..c7a756c 100644 --- a/exo/exo-execute.c +++ b/exo/exo-execute.c @@ -82,7 +82,12 @@ exo_execute_preferred_application (const gchar *category, return exo_execute_preferred_application_on_screen (category, parameter, working_directory, envp, gdk_screen_get_default (), error); } - +/* Set the DISPLAY variable, to be use by g_spawn_async. */ +static void +set_environment (gchar *display) +{ + g_setenv ("DISPLAY", display, TRUE); +} /** * exo_execute_preferred_application_on_screen: @@ -119,13 +124,12 @@ gboolean exo_execute_preferred_application_on_screen (const gchar *category, const gchar *parameter, const gchar *working_directory, - gchar **envp_in, + gchar **envp, GdkScreen *screen, GError **error) { gchar *argv[5]; gchar *display; - gchar **envp = g_strdupv (envp_in); gint argc = 0; gboolean success; @@ -147,13 +151,18 @@ exo_execute_preferred_application_on_screen (const gchar *category, /* set the display environment variable */ display = gdk_screen_make_display_name (screen); - envp = g_environ_setenv (envp, "DISPLAY", display, TRUE); /* launch the command */ - success = g_spawn_async (working_directory, argv, envp, 0, NULL, NULL, NULL, error); + success = g_spawn_async (working_directory, + argv, + envp, + 0, + (GSpawnChildSetupFunc) set_environment, + display, + NULL, + error); g_free (display); - g_strfreev (envp); return success; } |