allow setting startupnotify per execute action, default to disabled. use like this: <action name="execute"><execute>program</execute><startupnotify><enabled>true</enabled><name>something descriptive</name><icon>name of an icon in the icon theme to show</icon></startupnotify</action>
This commit is contained in:
parent
923e0edfa8
commit
c5d2a9bc98
4 changed files with 33 additions and 6 deletions
|
@ -929,6 +929,15 @@ ObAction *action_parse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
|
|||
act->data.execute.path = parse_expand_tilde(s);
|
||||
g_free(s);
|
||||
}
|
||||
if ((n = parse_find_node("startupnotify", node->xmlChildrenNode))) {
|
||||
xmlNodePtr m;
|
||||
if ((m = parse_find_node("enabled", n->xmlChildrenNode)))
|
||||
act->data.execute.startupnotify = parse_bool(doc, m);
|
||||
if ((m = parse_find_node("name", n->xmlChildrenNode)))
|
||||
act->data.execute.name = parse_string(doc, m);
|
||||
if ((m = parse_find_node("icon", n->xmlChildrenNode)))
|
||||
act->data.execute.icon_name = parse_string(doc, m);
|
||||
}
|
||||
} else if (act->func == action_showmenu) {
|
||||
if ((n = parse_find_node("menu", node->xmlChildrenNode)))
|
||||
act->data.showmenu.name = parse_string(doc, n);
|
||||
|
@ -1095,11 +1104,13 @@ void action_execute(union ActionData *data)
|
|||
g_warning("failed to execute '%s': %s",
|
||||
cmd, e->message);
|
||||
g_error_free(e);
|
||||
} else {
|
||||
} else if (data->execute.startupnotify) {
|
||||
gchar **env, *program;
|
||||
|
||||
program = g_path_get_basename(argv[0]);
|
||||
env = sn_get_spawn_environment(program,
|
||||
data->execute.name,
|
||||
data->execute.icon_name,
|
||||
data->execute.any.time);
|
||||
if (!g_spawn_async(NULL, argv, env, G_SPAWN_SEARCH_PATH |
|
||||
G_SPAWN_DO_NOT_REAP_CHILD,
|
||||
|
@ -1112,6 +1123,16 @@ void action_execute(union ActionData *data)
|
|||
g_strfreev(env);
|
||||
g_free(program);
|
||||
g_strfreev(argv);
|
||||
} else {
|
||||
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",
|
||||
cmd, e->message);
|
||||
g_error_free(e);
|
||||
}
|
||||
g_strfreev(argv);
|
||||
}
|
||||
g_free(cmd);
|
||||
} else {
|
||||
|
|
|
@ -72,6 +72,9 @@ struct DirectionalAction{
|
|||
struct Execute {
|
||||
struct AnyAction any;
|
||||
gchar *path;
|
||||
gboolean startupnotify;
|
||||
gchar *name;
|
||||
gchar *icon_name;
|
||||
};
|
||||
|
||||
struct ClientAction {
|
||||
|
|
|
@ -32,7 +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, Time time)
|
||||
gchar **sn_get_spawn_environment(char *program, char *name,
|
||||
char *icon_name, Time time)
|
||||
{
|
||||
return g_strdupv(environ);
|
||||
}
|
||||
|
@ -225,7 +226,8 @@ static gboolean sn_launch_wait_timeout(gpointer data)
|
|||
return FALSE; /* don't repeat */
|
||||
}
|
||||
|
||||
gchar **sn_get_spawn_environment(char *program, Time time)
|
||||
gchar **sn_get_spawn_environment(char *program, char *name,
|
||||
char *icon_name, Time time)
|
||||
{
|
||||
gchar **env, *desc;
|
||||
guint len;
|
||||
|
@ -238,9 +240,9 @@ gchar **sn_get_spawn_environment(char *program, Time time)
|
|||
sn_launcher = sn_launcher_context_new(sn_display, ob_screen);
|
||||
}
|
||||
|
||||
sn_launcher_context_set_name(sn_launcher, program);
|
||||
sn_launcher_context_set_name(sn_launcher, name ? name : program);
|
||||
sn_launcher_context_set_description(sn_launcher, desc);
|
||||
sn_launcher_context_set_icon_name(sn_launcher, program);
|
||||
sn_launcher_context_set_icon_name(sn_launcher, icon_name ? icon_name : program);
|
||||
sn_launcher_context_set_binary_name(sn_launcher, program);
|
||||
sn_launcher_context_initiate(sn_launcher, "openbox", program, time);
|
||||
id = sn_launcher_context_get_startup_id(sn_launcher);
|
||||
|
|
|
@ -35,7 +35,8 @@ 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, Time time);
|
||||
gchar **sn_get_spawn_environment(char *program, char *name,
|
||||
char *icon_name, Time time);
|
||||
|
||||
/* Tell startup notification we're not actually running the program we
|
||||
told it we were
|
||||
|
|
Loading…
Reference in a new issue