From e660b9de3f4331ebf171735b40eb12105218b2d7 Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Sun, 21 Nov 2010 23:15:02 -0700 Subject: set UZBL_UTIL_DIR in uzbl-browser, get rid of the scripts_util_dir variable --- src/uzbl-browser | 18 +++++++++++++++++- src/uzbl-core.c | 27 --------------------------- src/uzbl-core.h | 3 --- 3 files changed, 17 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/uzbl-browser b/src/uzbl-browser index de4f7af..865447c 100755 --- a/src/uzbl-browser +++ b/src/uzbl-browser @@ -10,6 +10,8 @@ # But this shouldn't cause much problems.. PREFIX=/usr/local +EXAMPLES=$PREFIX/share/uzbl/examples + if [ -z "$XDG_DATA_HOME" ] then export XDG_DATA_HOME=$HOME/.local/share @@ -40,13 +42,27 @@ done # if no config exists yet in the recommended location, put the default (recommended) config there if [ ! -f $XDG_CONFIG_HOME/uzbl/config ] then - if ! cp $PREFIX/share/uzbl/examples/config/config $XDG_CONFIG_HOME/uzbl/config + if ! cp "$EXAMPLES"/config/config $XDG_CONFIG_HOME/uzbl/config then echo "Could not copy default config to $XDG_CONFIG_HOME/uzbl/config" >&2 exit 3 fi fi +# this variable is used by the default helper scripts as a location to +# load shared code from +if [ -z "$UZBL_UTIL_DIR" ] +then + if [ -d "$XDG_DATA_HOME"/uzbl/scripts/util ] + then + UZBL_UTIL_DIR=$XDG_DATA_HOME/uzbl/scripts/util + elif [ -d $EXAMPLES/data/scripts/util ] + then + UZBL_UTIL_DIR=$EXAMPLES/data/scripts/util + fi + export UZBL_UTIL_DIR +fi + # Uncomment this for a slight speedup at the expense of not having # stale cookie daemon sockets cleaned up. #if [ ! -S $XDG_CACHE_HOME/uzbl/cookie_daemon_socket ] diff --git a/src/uzbl-core.c b/src/uzbl-core.c index 13328d0..fd589c0 100644 --- a/src/uzbl-core.c +++ b/src/uzbl-core.c @@ -1263,29 +1263,6 @@ 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, @@ -1297,7 +1274,6 @@ 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 */ @@ -1337,9 +1313,6 @@ run_command (const gchar *command, const guint npre, const gchar **args, printf("Stdout: %s\n", *output_stdout); } } - if (!environ_set) { - g_printerr("failed to set the environment for scripts"); - } if (err) { g_printerr("error on run_command: %s\n", err->message); g_error_free (err); diff --git a/src/uzbl-core.h b/src/uzbl-core.h index 15f7299..5760423 100644 --- a/src/uzbl-core.h +++ b/src/uzbl-core.h @@ -273,9 +273,6 @@ 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