all repos — openbox @ c5d2a9bc98fb7d1ed85c69fc3007ab36b9fd96d5

openbox fork - make it a bit more like ryudo

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>
Mikael Magnusson mikachu@comhem.se
commit

c5d2a9bc98fb7d1ed85c69fc3007ab36b9fd96d5

parent

923e0edfa80dbfe7e9fa90bee8f6bb2dfb2f9907

4 files changed, 33 insertions(+), 6 deletions(-)

jump to
M openbox/action.copenbox/action.c

@@ -929,6 +929,15 @@ gchar *s = parse_string(doc, n);

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 @@ if (!g_shell_parse_argv (cmd, NULL, &argv, &e)) {

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,

@@ -1111,6 +1122,16 @@ sn_spawn_cancel();

} 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);
M openbox/action.hopenbox/action.h

@@ -72,6 +72,9 @@

struct Execute { struct AnyAction any; gchar *path; + gboolean startupnotify; + gchar *name; + gchar *icon_name; }; struct ClientAction {
M openbox/startupnotify.copenbox/startupnotify.c

@@ -32,7 +32,8 @@ {

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 @@ sn_launcher_context_complete(sn);

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 @@ sn_launcher_context_unref(sn_launcher);

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);
M openbox/startupnotify.hopenbox/startupnotify.h

@@ -35,7 +35,8 @@ was requested */

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