cosmetix
[k8lowj.git] / src / spawn.c
blob58a0ae759b37c8dd0865778a615ff8612c802bf3
1 /* logjam - a GTK client for LiveJournal.
2 * Copyright (C) 2000-2003 Evan Martin <evan@livejournal.com>
4 * vim: tabstop=4 shiftwidth=4 noexpandtab :
5 */
7 #include "glib-all.h"
8 #include "util-gtk.h"
9 #include <stdio.h>
11 #include <unistd.h>
13 #include <sys/types.h>
14 #include <sys/wait.h>
15 #include <signal.h>
17 #include "conf.h"
18 #include "spawn.h"
20 /* http://lxr.mozilla.org/seamonkey/source/xpfe/bootstrap/nsAppRunner.cpp#1413
21 * when sending remote commands,
22 * mozilla returns 0 on success and nonzero on failure. */
23 const CommandList spawn_commands[] = {
24 {"Firefox", "firefox '%s'"},
25 //{"Opera", "opera -remote 'openURL(%s,new-window)' || opera '%s'"},
26 {"Opera", "opera '%s'"},
27 //{"Mozilla", "mozilla -remote 'openURL(%s, new-window)' || mozilla '%s'"},
28 {"Mozilla", "mozilla '%s'"},
29 {0, 0}
33 void spawn_url (GtkWindow *parent, const char *url) {
34 char *cmd;
35 GError *err = NULL;
36 char *argv[4] = { "/bin/sh", "-c", NULL, NULL };
37 /* and now, a hack because I don't know how many %s's are in spawn_command. */
38 #define ARGS_HACK url,url,url,url,url,url
39 cmd = g_strdup_printf(conf.spawn_command, ARGS_HACK);
40 argv[2] = cmd;
41 if (!g_spawn_async(NULL, argv, NULL, 0, NULL, NULL, NULL, &err)) {
42 jam_warning(parent, _("Error spawning URL '%s': %s\n"), url, err->message);
43 g_error_free(err);
45 g_free(cmd);