From bb1153c9bc776d0c0dde44bcc055d40c7617a998 Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Sun, 21 Nov 2010 23:12:48 -0700 Subject: write new history and bookmark files if they don't already exist --- examples/data/scripts/history.sh | 2 +- examples/data/scripts/insert_bookmark.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/data/scripts/history.sh b/examples/data/scripts/history.sh index b91d415..0cd2218 100755 --- a/examples/data/scripts/history.sh +++ b/examples/data/scripts/history.sh @@ -2,6 +2,6 @@ source $UZBL_UTIL_DIR/uzbl-dir.sh -[ -w "$UZBL_HISTORY_FILE" ] || exit 1 +[ -w "$UZBL_HISTORY_FILE" ] || [ ! -a "$UZBL_HISTORY_FILE" ] || exit 1 echo $(date +'%Y-%m-%d %H:%M:%S')" $6 $7" >> $UZBL_HISTORY_FILE diff --git a/examples/data/scripts/insert_bookmark.sh b/examples/data/scripts/insert_bookmark.sh index 18f643f..08d7d2b 100755 --- a/examples/data/scripts/insert_bookmark.sh +++ b/examples/data/scripts/insert_bookmark.sh @@ -3,7 +3,7 @@ source $UZBL_UTIL_DIR/uzbl-dir.sh [ -d "$UZBL_DATA_DIR" ] || exit 1 -[ -w "$UZBL_BOOKMARKS_FILE" ] || exit 1 +[ -w "$UZBL_BOOKMARKS_FILE" ] || [ ! -a "$UZBL_BOOKMARKS_FILE" ] || exit 1 which zenity &>/dev/null || exit 2 # replace tabs, they are pointless in titles and we want to use tabs as delimiter. -- cgit v1.2.3 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 --- examples/config/config | 1 - src/uzbl-browser | 18 +++++++++++++++++- src/uzbl-core.c | 27 --------------------------- src/uzbl-core.h | 3 --- 4 files changed, 17 insertions(+), 32 deletions(-) diff --git a/examples/config/config b/examples/config/config index 847b4af..1457c71 100644 --- a/examples/config/config +++ b/examples/config/config @@ -35,7 +35,6 @@ set set_status = set status_message = # Spawn path shortcuts. In spawn the first dir+path match is used in "dir1:dir2:dir3:executable" set scripts_dir = $XDG_DATA_HOME/uzbl:@prefix/share/uzbl/examples/data:scripts -set scripts_util_dir = @scripts_dir/util # === Hardcoded handlers ===================================================== 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