use setenv to set up the DESKTOP_STARTUP_ID when launching programs.
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.
This commit is contained in:
parent
3ad050f7d8
commit
f746a4975b
3 changed files with 21 additions and 28 deletions
|
@ -1103,17 +1103,18 @@ void action_execute(union ActionData *data)
|
||||||
cmd, e->message);
|
cmd, e->message);
|
||||||
g_error_free(e);
|
g_error_free(e);
|
||||||
} else if (data->execute.startupnotify) {
|
} else if (data->execute.startupnotify) {
|
||||||
gchar **env, *program;
|
gchar *program;
|
||||||
|
|
||||||
program = g_path_get_basename(argv[0]);
|
program = g_path_get_basename(argv[0]);
|
||||||
env = sn_get_spawn_environment(program,
|
/* sets up the environment */
|
||||||
data->execute.name,
|
sn_setup_spawn_environment(program,
|
||||||
data->execute.icon_name,
|
data->execute.name,
|
||||||
/* launch it on the current
|
data->execute.icon_name,
|
||||||
desktop */
|
/* launch it on the current
|
||||||
screen_desktop,
|
desktop */
|
||||||
data->execute.any.time);
|
screen_desktop,
|
||||||
if (!g_spawn_async(NULL, argv, env, G_SPAWN_SEARCH_PATH |
|
data->execute.any.time);
|
||||||
|
if (!g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH |
|
||||||
G_SPAWN_DO_NOT_REAP_CHILD,
|
G_SPAWN_DO_NOT_REAP_CHILD,
|
||||||
NULL, NULL, NULL, &e)) {
|
NULL, NULL, NULL, &e)) {
|
||||||
g_warning("failed to execute '%s': %s",
|
g_warning("failed to execute '%s': %s",
|
||||||
|
@ -1121,7 +1122,6 @@ void action_execute(union ActionData *data)
|
||||||
g_error_free(e);
|
g_error_free(e);
|
||||||
sn_spawn_cancel();
|
sn_spawn_cancel();
|
||||||
}
|
}
|
||||||
g_strfreev(env);
|
|
||||||
g_free(program);
|
g_free(program);
|
||||||
g_strfreev(argv);
|
g_strfreev(argv);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "startupnotify.h"
|
#include "startupnotify.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
|
|
||||||
extern gchar **environ;
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifndef USE_LIBSN
|
#ifndef USE_LIBSN
|
||||||
|
|
||||||
|
@ -32,8 +32,8 @@ Time sn_app_started(const gchar *id, const gchar *wmclass)
|
||||||
return CurrentTime;
|
return CurrentTime;
|
||||||
}
|
}
|
||||||
gboolean sn_get_desktop(gchar *id, guint *desktop) { return FALSE; }
|
gboolean sn_get_desktop(gchar *id, guint *desktop) { return FALSE; }
|
||||||
gchar **sn_get_spawn_environment(char *program, char *name,
|
void sn_setup_spawn_environment(gchar *program, gchar *name,
|
||||||
char *icon_name, gint desktop, Time time)
|
gchar *icon_name, gint desktop, Time time)
|
||||||
{
|
{
|
||||||
return g_strdupv(environ);
|
return g_strdupv(environ);
|
||||||
}
|
}
|
||||||
|
@ -226,12 +226,11 @@ static gboolean sn_launch_wait_timeout(gpointer data)
|
||||||
return FALSE; /* don't repeat */
|
return FALSE; /* don't repeat */
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar **sn_get_spawn_environment(char *program, char *name,
|
void sn_setup_spawn_environment(gchar *program, gchar *name,
|
||||||
char *icon_name, gint desktop,
|
gchar *icon_name, gint desktop,
|
||||||
Time time)
|
Time time)
|
||||||
{
|
{
|
||||||
gchar **env, *desc;
|
gchar *desc;
|
||||||
guint len;
|
|
||||||
const char *id;
|
const char *id;
|
||||||
|
|
||||||
desc = g_strdup_printf(_("Running %s\n"), program);
|
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,
|
sn_launch_wait_timeout, sn_launcher,
|
||||||
(GDestroyNotify)sn_launcher_context_unref);
|
(GDestroyNotify)sn_launcher_context_unref);
|
||||||
|
|
||||||
env = g_strdupv(environ);
|
setenv("DESKTOP_STARTUP_ID", id, TRUE);
|
||||||
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;
|
|
||||||
|
|
||||||
g_free(desc);
|
g_free(desc);
|
||||||
|
|
||||||
return env;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void sn_spawn_cancel()
|
void sn_spawn_cancel()
|
||||||
|
|
|
@ -35,9 +35,9 @@ Time sn_app_started(const gchar *id, const gchar *wmclass);
|
||||||
gboolean sn_get_desktop(gchar *id, guint *desktop);
|
gboolean sn_get_desktop(gchar *id, guint *desktop);
|
||||||
|
|
||||||
/* Get the environment to run the program in, with startup notification */
|
/* Get the environment to run the program in, with startup notification */
|
||||||
gchar **sn_get_spawn_environment(char *program, char *name,
|
void sn_setup_spawn_environment(gchar *program, gchar *name,
|
||||||
char *icon_name, gint desktop,
|
gchar *icon_name, gint desktop,
|
||||||
Time time);
|
Time time);
|
||||||
|
|
||||||
/* Tell startup notification we're not actually running the program we
|
/* Tell startup notification we're not actually running the program we
|
||||||
told it we were
|
told it we were
|
||||||
|
|
Loading…
Reference in a new issue