Skip to content

Commit

Permalink
Add action: sh, add var: shell_cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
hmkemppainen committed May 16, 2009
1 parent 6c45107 commit 10431d4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions uzbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -734,6 +736,14 @@ spawn(WebKitWebView *web_view, const char *param) {
run_command(param, NULL, FALSE, NULL);
}

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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions uzbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -246,6 +247,9 @@ run_command(const char *command, const char *args, const gboolean sync, char **s
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);

Expand Down

0 comments on commit 10431d4

Please sign in to comment.