aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/uzbl-browser
diff options
context:
space:
mode:
Diffstat (limited to 'src/uzbl-browser')
-rwxr-xr-xsrc/uzbl-browser73
1 files changed, 45 insertions, 28 deletions
diff --git a/src/uzbl-browser b/src/uzbl-browser
index 9f6847b..88d3742 100755
--- a/src/uzbl-browser
+++ b/src/uzbl-browser
@@ -8,27 +8,23 @@
# to your $XDG_DATA_HOME/uzbl/scripts/ and edit them
PREFIX=/usr/local
-if [ -z "$XDG_DATA_HOME" ]
-then
- export XDG_DATA_HOME=$HOME/.local/share
-fi
+EXAMPLES=$PREFIX/share/uzbl/examples
-if [ -z "$XDG_CACHE_HOME" ]
-then
- export XDG_CACHE_HOME=$HOME/.cache
-fi
+XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share}
+export XDG_DATA_HOME
-if [ -z "$XDG_CONFIG_HOME" ]
-then
- export XDG_CONFIG_HOME=$HOME/.config
-fi
+XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache}
+export XDG_CACHE_HOME
+
+XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}
+export XDG_CONFIG_HOME
# assure the relevant directories exist.
-for dir in $XDG_CACHE_HOME/uzbl $XDG_DATA_HOME/uzbl $XDG_CONFIG_HOME/uzbl
+for dir in "$XDG_CACHE_HOME"/uzbl "$XDG_DATA_HOME"/uzbl "$XDG_CONFIG_HOME"/uzbl
do
- if [ ! -d $dir ]
+ if [ ! -d "$dir" ]
then
- if ! mkdir -p $dir
+ if ! mkdir -p "$dir"
then
echo "could not create $dir" >&2
exit 2
@@ -37,27 +33,48 @@ do
done
# if no config exists yet in the recommended location, put the default (recommended) config there
-if [ ! -f $XDG_CONFIG_HOME/uzbl/config ]
+if [ ! -f "$XDG_CONFIG_HOME"/uzbl/config ]
then
- if ! cp $PREFIX/share/uzbl/examples/config/config $XDG_CONFIG_HOME/uzbl/config
+ if [ ! -r "$EXAMPLES"/config/config ]
then
- echo "Could not copy default config to $XDG_CONFIG_HOME/uzbl/config" >&2
+ echo "Error: Global config not found; please check if your distribution ships them separately"
exit 3
fi
+ 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=$EXAMPLES/config/config
+ fi
fi
-# uzbl-cookie-manager will exit if another instance is already running
-uzbl-cookie-manager
+# 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
-DAEMON_SOCKET=$XDG_CACHE_HOME/uzbl/event_daemon
-DAEMON_PID=${DAEMON_SOCKET}.pid
+# 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 ]
+#then
+ ${UZBL_COOKIE_DAEMON:-uzbl-cookie-manager}
+#fi
-# uzbl-event-manager will exit if one is already running, but you could
-# check if the pid file exists here to avoid having to spawn it for a
-# slight speedup
-#if [ -f "$DAEMON_PID" ]
+# uzbl-event-manager will exit if one is already running.
+# we could also check if its pid file exists to avoid having to spawn it.
+DAEMON_SOCKET="$XDG_CACHE_HOME"/uzbl/event_daemon
+#if [ ! -f "$DAEMON_SOCKET".pid ]
#then
- uzbl-event-manager -va start
+ ${UZBL_EVENT_MANAGER:-uzbl-event-manager -va start}
#fi
-exec uzbl-core "$@" --connect-socket $DAEMON_SOCKET
+exec uzbl-core "$@" ${config_file:+--config "$config_file"} --connect-socket $DAEMON_SOCKET