]> Dogcows Code - chaz/openbox/commitdiff
use setenv to set up the DESKTOP_STARTUP_ID when launching programs.
authorDana Jansens <danakj@orodu.net>
Wed, 28 Mar 2007 06:00:19 +0000 (06:00 +0000)
committerDana Jansens <danakj@orodu.net>
Wed, 28 Mar 2007 06:00:19 +0000 (06:00 +0000)
before, if DESKTOP_STARTUP_ID was set in openbox, it would mess up adding it to the child's environment because it would appear twice. so now it will only appear once for the child always.

openbox/action.c
openbox/startupnotify.c
openbox/startupnotify.h

index 796f259a312d300f04a8838943540db7d1b8fa3b..9022333a1857faed249000b0961967254460c6f3 100644 (file)
@@ -1103,17 +1103,18 @@ void action_execute(union ActionData *data)
                           cmd, e->message);
                 g_error_free(e);
             } else if (data->execute.startupnotify) {
-                gchar **env, *program;
+                gchar *program;
                 
                 program = g_path_get_basename(argv[0]);
-                env = sn_get_spawn_environment(program,
-                                               data->execute.name,
-                                               data->execute.icon_name,
-                                               /* launch it on the current
-                                                  desktop */
-                                               screen_desktop,
-                                               data->execute.any.time);
-                if (!g_spawn_async(NULL, argv, env, G_SPAWN_SEARCH_PATH |
+                /* sets up the environment */
+                sn_setup_spawn_environment(program,
+                                           data->execute.name,
+                                           data->execute.icon_name,
+                                           /* launch it on the current
+                                              desktop */
+                                           screen_desktop,
+                                           data->execute.any.time);
+                if (!g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH |
                                    G_SPAWN_DO_NOT_REAP_CHILD,
                                    NULL, NULL, NULL, &e)) {
                     g_warning("failed to execute '%s': %s",
@@ -1121,7 +1122,6 @@ void action_execute(union ActionData *data)
                     g_error_free(e);
                     sn_spawn_cancel();
                 }
-                g_strfreev(env);
                 g_free(program);
                 g_strfreev(argv);
             } else {
index b9bbab727e8ef2534c499e2461ef94139c309e8d..4c2672c1857c5f3ed580702cebb7f1ae9fd4b598 100644 (file)
@@ -20,7 +20,7 @@
 #include "startupnotify.h"
 #include "gettext.h"
 
-extern gchar **environ;
+#include <stdlib.h>
 
 #ifndef USE_LIBSN
 
@@ -32,8 +32,8 @@ Time sn_app_started(const gchar *id, const gchar *wmclass)
     return CurrentTime;
 }
 gboolean sn_get_desktop(gchar *id, guint *desktop) { return FALSE; }
-gchar **sn_get_spawn_environment(char *program, char *name,
-                                 char *icon_name, gint desktop, Time time)
+void sn_setup_spawn_environment(gchar *program, gchar *name,
+                                gchar *icon_name, gint desktop, Time time)
 {
     return g_strdupv(environ);
 }
@@ -226,12 +226,11 @@ static gboolean sn_launch_wait_timeout(gpointer data)
     return FALSE; /* don't repeat */
 }
 
-gchar **sn_get_spawn_environment(char *program, char *name,
-                                 char *icon_name, gint desktop,
-                                 Time time)
+void sn_setup_spawn_environment(gchar *program, gchar *name,
+                                gchar *icon_name, gint desktop,
+                                Time time)
 {
-    gchar **env, *desc;
-    guint len;
+    gchar *desc;
     const char *id;
 
     desc = g_strdup_printf(_("Running %s\n"), program);
@@ -256,15 +255,9 @@ gchar **sn_get_spawn_environment(char *program, char *name,
                              sn_launch_wait_timeout, sn_launcher,
                              (GDestroyNotify)sn_launcher_context_unref);
 
-    env = g_strdupv(environ);
-    len = g_strv_length(env); /* includes last null */
-    env = g_renew(gchar*, env, ++len); /* add one spot */
-    env[len-2] = g_strdup_printf("DESKTOP_STARTUP_ID=%s", id);
-    env[len-1] = NULL;
+    setenv("DESKTOP_STARTUP_ID", id, TRUE);
 
     g_free(desc);
-
-    return env;
 }
 
 void sn_spawn_cancel()
index 87b17f90f083206b5d187fe65420a51da358a372..746b786e93eae3c4c099dda9681a1a60e477d76c 100644 (file)
@@ -35,9 +35,9 @@ Time sn_app_started(const gchar *id, const gchar *wmclass);
 gboolean sn_get_desktop(gchar *id, guint *desktop);
 
 /* Get the environment to run the program in, with startup notification */
-gchar **sn_get_spawn_environment(char *program, char *name,
-                                 char *icon_name, gint desktop,
-                                 Time time);
+void sn_setup_spawn_environment(gchar *program, gchar *name,
+                                gchar *icon_name, gint desktop,
+                                Time time);
 
 /* Tell startup notification we're not actually running the program we
    told it we were
This page took 0.031008 seconds and 4 git commands to generate.