Add action: sh, add var: shell_cmd
authorDuClare <akarinotengoku@gmail.com>
Sat, 16 May 2009 17:31:49 +0000 (20:31 +0300)
committerDuClare <akarinotengoku@gmail.com>
Sat, 16 May 2009 17:31:49 +0000 (20:31 +0300)
uzbl.c
uzbl.h

diff --git a/uzbl.c b/uzbl.c
index 4b64a09..3d86892 100644 (file)
--- a/uzbl.c
+++ b/uzbl.c
@@ -82,6 +82,7 @@ const struct {
     { "http_debug",         (void *)&uzbl.behave.http_debug         },
     { "default_font_size",  (void *)&uzbl.behave.default_font_size  },
     { "minimum_font_size",  (void *)&uzbl.behave.minimum_font_size  },
+    { "shell_cmd",          (void *)&uzbl.behave.shell_cmd          },
     { "proxy_url",          (void *)&uzbl.net.proxy_url             },
     { "max_conns",          (void *)&uzbl.net.max_conns             },
     { "max_conns_host",     (void *)&uzbl.net.max_conns_host        },
@@ -401,6 +402,7 @@ static struct {char *name; Command command;} cmdlist[] =
     { "script",           run_js                  },
     { "toggle_status",    toggle_status_cb        },
     { "spawn",            spawn                   },
+    { "sh",               spawn_sh                },
     { "exit",             close_uzbl              },
     { "search",           search_text             },
     { "insert_mode",      set_insert_mode         },
@@ -735,6 +737,14 @@ spawn(WebKitWebView *web_view, const char *param) {
 }
 
 static void
+spawn_sh(WebKitWebView *web_view, const char *param) {
+    (void)web_view;
+    gchar *cmd = g_strdup_printf(uzbl.behave.shell_cmd, param);
+    spawn(NULL, cmd);
+    g_free(cmd);
+}
+
+static void
 parse_command(const char *cmd, const char *param) {
     Command c;
 
@@ -869,6 +879,10 @@ set_var_value(gchar *name, gchar *val) {
             if(*p) free(*p);
             *p = set_useragent(g_strdup(val));
         }
+        else if(var_is("shell_cmd", name)) {
+            if(*p) free(*p);
+            *p = g_strdup(val);
+        }
         /* variables that take int values */
         else {
             int *ip = (int *)p;
diff --git a/uzbl.h b/uzbl.h
index 0a01328..39d94a3 100644 (file)
--- a/uzbl.h
+++ b/uzbl.h
@@ -138,6 +138,7 @@ typedef struct {
     guint    http_debug;
     guint    default_font_size;
     guint    minimum_font_size;
+    gchar*   shell_cmd;
 
     /* command list: name -> Command  */
     GHashTable* commands;
@@ -247,6 +248,9 @@ static void
 spawn(WebKitWebView *web_view, const char *param);
 
 static void
+spawn_sh(WebKitWebView *web_view, const char *param);
+
+static void
 parse_command(const char *cmd, const char *param);
 
 static void