diff options
author | Brendan Taylor <whateley@gmail.com> | 2010-11-21 23:25:17 -0700 |
---|---|---|
committer | Brendan Taylor <whateley@gmail.com> | 2010-11-21 23:25:17 -0700 |
commit | 2fbd3ecfd2697f5883228c1ff8ddae65a5e48322 (patch) | |
tree | 5340c0d3912c2cda2b5d481070d86bd4b61652df | |
parent | f140884503c05d20bbd88114a1f1f10b6de067ef (diff) | |
parent | e660b9de3f4331ebf171735b40eb12105218b2d7 (diff) |
Merge branch 'dev/cleanup-scripts'
Conflicts:
src/uzbl-browser
-rw-r--r-- | examples/config/config | 1 | ||||
-rwxr-xr-x | examples/data/scripts/history.sh | 2 | ||||
-rwxr-xr-x | examples/data/scripts/insert_bookmark.sh | 2 | ||||
-rwxr-xr-x | src/uzbl-browser | 22 | ||||
-rw-r--r-- | src/uzbl-core.c | 27 | ||||
-rw-r--r-- | src/uzbl-core.h | 3 |
6 files changed, 20 insertions, 37 deletions
diff --git a/examples/config/config b/examples/config/config index 7c3a950..8189479 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/examples/data/scripts/history.sh b/examples/data/scripts/history.sh index b8a15e0..0561fe9 100755 --- a/examples/data/scripts/history.sh +++ b/examples/data/scripts/history.sh @@ -2,6 +2,6 @@ . $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 bd6f1bd..65fb5c5 100755 --- a/examples/data/scripts/insert_bookmark.sh +++ b/examples/data/scripts/insert_bookmark.sh @@ -3,7 +3,7 @@ . $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 2>&1 >/dev/null || exit 2 # replace tabs, they are pointless in titles and we want to use tabs as delimiter. diff --git a/src/uzbl-browser b/src/uzbl-browser index 9756ed1..88d3742 100755 --- a/src/uzbl-browser +++ b/src/uzbl-browser @@ -8,6 +8,7 @@ # to your $XDG_DATA_HOME/uzbl/scripts/ and edit them PREFIX=/usr/local +EXAMPLES=$PREFIX/share/uzbl/examples XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share} export XDG_DATA_HOME @@ -34,20 +35,33 @@ done # if no config exists yet in the recommended location, put the default (recommended) config there if [ ! -f "$XDG_CONFIG_HOME"/uzbl/config ] then - global_config=$PREFIX/share/uzbl/examples/config/config - if [ ! -r "$global_config" ] + if [ ! -r "$EXAMPLES"/config/config ] then echo "Error: Global config not found; please check if your distribution ships them separately" exit 3 fi - if ! cp "$global_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 # Run with the global config as a last resort - config_file=$global_config + config_file=$EXAMPLES/config/config 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 + # uzbl-cookie-manager will exit if another instance is already running. # we could also check if its pid file exists to avoid having to spawn it. #if [ ! -f "$XDG_CACHE_HOME"/uzbl/cookie_daemon_socket.pid ] diff --git a/src/uzbl-core.c b/src/uzbl-core.c index 7e1d31b..cb20fd7 100644 --- a/src/uzbl-core.c +++ b/src/uzbl-core.c @@ -1209,29 +1209,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, @@ -1243,7 +1220,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 */ @@ -1283,9 +1259,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 33dfb01..b5a502e 100644 --- a/src/uzbl-core.h +++ b/src/uzbl-core.h @@ -262,9 +262,6 @@ 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); |