From 7b8070d9997dc26d825467d3e78419d2ac51c985 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 2 Oct 2010 12:57:27 -0400 Subject: Set up the environment with the util dir The new scripts require that the utility directory be set through the environment. Add a function which sets it up. --- src/uzbl-core.c | 25 +++++++++++++++++++++++++ src/uzbl-core.h | 3 +++ 2 files changed, 28 insertions(+) (limited to 'src') diff --git a/src/uzbl-core.c b/src/uzbl-core.c index 7be98c3..129bb2a 100644 --- a/src/uzbl-core.c +++ b/src/uzbl-core.c @@ -1263,6 +1263,29 @@ sharg_append(GArray *a, const gchar *str) { g_array_append_val(a, s); } +gboolean +uzbl_setup_environ() { + gchar *util_dirs = expand("@scripts_util_dir", 0); + gchar *util_dir = NULL; + gboolean succeed = FALSE; + + if(!util_dirs) { + g_free(util_dirs); + return succeed; + } + + if(!(util_dir = find_existing_file(util_dirs))) { + g_free(util_dirs); + return succeed; + } + + succeed = g_setenv("UZBL_UTIL_DIR", util_dir, TRUE); + + g_free(util_dirs); + g_free(util_dir); + return succeed; +} + // make sure that the args string you pass can properly be interpreted (eg properly escaped against whitespace, quotes etc) gboolean run_command (const gchar *command, const guint npre, const gchar **args, @@ -1274,6 +1297,8 @@ run_command (const gchar *command, const guint npre, const gchar **args, gchar *pid = itos(getpid()); gchar *xwin = itos(uzbl.xwin); guint i; + gboolean environ_set = uzbl_setup_environ(); + sharg_append(a, command); for (i = 0; i < npre; i++) /* add n args before the default vars */ sharg_append(a, args[i]); diff --git a/src/uzbl-core.h b/src/uzbl-core.h index 5760423..15f7299 100644 --- a/src/uzbl-core.h +++ b/src/uzbl-core.h @@ -273,6 +273,9 @@ chain (WebKitWebView *page, GArray *argv, GString *result); void close_uzbl (WebKitWebView *page, GArray *argv, GString *result); +gboolean +uzbl_setup_environ(); + gboolean run_command(const gchar *command, const guint npre, const gchar **args, const gboolean sync, char **output_stdout); -- cgit v1.2.3