+static gboolean sn_launch_wait_timeout(gpointer data)
+{
+ SnLauncherContext *sn = data;
+ sn_launcher_context_complete(sn);
+ XFlush(obt_display);
+ return FALSE; /* don't repeat */
+}
+
+void sn_setup_spawn_environment(const gchar *program, const gchar *name,
+ const gchar *icon_name, const gchar *wmclass,
+ gint desktop)
+{
+ gchar *desc;
+ const char *id;
+
+ desc = g_strdup_printf(_("Running %s"), program);
+
+ if (sn_launcher_context_get_initiated(sn_launcher)) {
+ sn_launcher_context_unref(sn_launcher);
+ sn_launcher = sn_launcher_context_new(sn_display, ob_screen);
+ }
+
+ 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, icon_name ?
+ icon_name : program);
+ sn_launcher_context_set_binary_name(sn_launcher, program);
+ if (wmclass) sn_launcher_context_set_wmclass(sn_launcher, wmclass);
+ if (desktop >= 0 && (unsigned) desktop < screen_num_desktops)
+ sn_launcher_context_set_workspace(sn_launcher, (signed) desktop);
+ sn_launcher_context_initiate(sn_launcher, "openbox", program,
+ event_time());
+ id = sn_launcher_context_get_startup_id(sn_launcher);
+
+ /* 20 second timeout for apps to start */
+ sn_launcher_context_ref(sn_launcher);
+ g_timeout_add_full(G_PRIORITY_DEFAULT,
+ 20 * 1000, sn_launch_wait_timeout, sn_launcher,
+ (GDestroyNotify)sn_launcher_context_unref);
+
+ setenv("DESKTOP_STARTUP_ID", id, TRUE);
+
+ g_free(desc);
+}
+
+void sn_spawn_cancel(void)
+{
+ sn_launcher_context_complete(sn_launcher);
+}
+