summaryrefslogtreecommitdiff
path: root/openbox
diff options
context:
space:
mode:
authorMikael Magnusson <mikachu@comhem.se>2007-03-11 15:41:47 +0000
committerMikael Magnusson <mikachu@comhem.se>2007-03-11 15:41:47 +0000
commitc5d2a9bc98fb7d1ed85c69fc3007ab36b9fd96d5 (patch)
tree27531a3b9b26adda3e1853ca8b8f62d88a1b76b6 /openbox
parent923e0edfa80dbfe7e9fa90bee8f6bb2dfb2f9907 (diff)
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>
Diffstat (limited to 'openbox')
-rw-r--r--openbox/action.c23
-rw-r--r--openbox/action.h3
-rw-r--r--openbox/startupnotify.c10
-rw-r--r--openbox/startupnotify.h3
4 files changed, 33 insertions, 6 deletions
diff --git a/openbox/action.c b/openbox/action.c
index 7d41d712..5cd39f3d 100644
--- a/openbox/action.c
+++ b/openbox/action.c
@@ -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 {
diff --git a/openbox/action.h b/openbox/action.h
index 639db018..c8e91cfa 100644
--- a/openbox/action.h
+++ b/openbox/action.h
@@ -72,6 +72,9 @@ struct DirectionalAction{
struct Execute {
struct AnyAction any;
gchar *path;
+ gboolean startupnotify;
+ gchar *name;
+ gchar *icon_name;
};
struct ClientAction {
diff --git a/openbox/startupnotify.c b/openbox/startupnotify.c
index 5db9bd48..954b9d4a 100644
--- a/openbox/startupnotify.c
+++ b/openbox/startupnotify.c
@@ -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);
diff --git a/openbox/startupnotify.h b/openbox/startupnotify.h
index 533ff9c6..850f39a7 100644
--- a/openbox/startupnotify.h
+++ b/openbox/startupnotify.h
@@ -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