12
|
1 |
#!/bin/sh
|
|
2 |
#
|
|
3 |
# This script implements a more useful out-of-the-box "browsing experience".
|
|
4 |
# It does so by combining uzbl-core with a set of "recommended" tools and
|
|
5 |
# practices. See docs for more info.
|
|
6 |
#
|
|
7 |
# If you want to customize the behavior any of the helper tools, copy them
|
|
8 |
# to your $XDG_DATA_HOME/uzbl/scripts/ and edit them
|
|
9 |
|
|
10 |
PREFIX=/usr/local
|
|
11 |
export PREFIX
|
|
12 |
|
|
13 |
EXAMPLES=$PREFIX/share/uzbl/examples
|
|
14 |
|
|
15 |
XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share}
|
|
16 |
export XDG_DATA_HOME
|
|
17 |
|
|
18 |
XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache}
|
|
19 |
export XDG_CACHE_HOME
|
|
20 |
|
|
21 |
XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}
|
|
22 |
export XDG_CONFIG_HOME
|
|
23 |
|
|
24 |
# assure the relevant directories exist.
|
|
25 |
for dir in "$XDG_CACHE_HOME"/uzbl "$XDG_DATA_HOME"/uzbl "$XDG_CONFIG_HOME"/uzbl
|
|
26 |
do
|
|
27 |
if [ ! -d "$dir" ]
|
|
28 |
then
|
|
29 |
if ! mkdir -p "$dir"
|
|
30 |
then
|
|
31 |
echo "could not create $dir" >&2
|
|
32 |
exit 2
|
|
33 |
fi
|
|
34 |
fi
|
|
35 |
done
|
|
36 |
|
|
37 |
# if no config exists yet in the recommended location, put the default (recommended) config there
|
|
38 |
if [ ! -f "$XDG_CONFIG_HOME"/uzbl/config ]
|
|
39 |
then
|
|
40 |
if [ ! -r "$EXAMPLES"/config/config ]
|
|
41 |
then
|
|
42 |
echo "Error: Global config not found; please check if your distribution ships them separately"
|
|
43 |
exit 3
|
|
44 |
fi
|
|
45 |
if ! cp "$EXAMPLES"/config/* "$XDG_CONFIG_HOME"/uzbl/
|
|
46 |
then
|
|
47 |
echo "Could not copy default config to $XDG_CONFIG_HOME/uzbl/config" >&2
|
|
48 |
# Run with the global config as a last resort
|
|
49 |
config_file=$EXAMPLES/config/config
|
|
50 |
fi
|
|
51 |
fi
|
|
52 |
|
|
53 |
# this variable is used by the default helper scripts as a location to
|
|
54 |
# load shared code from
|
|
55 |
if [ -z "$UZBL_UTIL_DIR" ]
|
|
56 |
then
|
|
57 |
if [ -d "$XDG_DATA_HOME"/uzbl/scripts/util ]
|
|
58 |
then
|
|
59 |
UZBL_UTIL_DIR=$XDG_DATA_HOME/uzbl/scripts/util
|
|
60 |
elif [ -d $EXAMPLES/data/scripts/util ]
|
|
61 |
then
|
|
62 |
UZBL_UTIL_DIR=$EXAMPLES/data/scripts/util
|
|
63 |
fi
|
|
64 |
export UZBL_UTIL_DIR
|
|
65 |
fi
|
|
66 |
|
|
67 |
# uzbl-event-manager will exit if one is already running.
|
|
68 |
# we could also check if its pid file exists to avoid having to spawn it.
|
|
69 |
DAEMON_SOCKET="$XDG_CACHE_HOME"/uzbl/event_daemon
|
|
70 |
#if [ ! -f "$DAEMON_SOCKET".pid ]
|
|
71 |
#then
|
|
72 |
${UZBL_EVENT_MANAGER:-uzbl-event-manager -va start}
|
|
73 |
#fi
|
|
74 |
|
|
75 |
exec uzbl-core "$@" ${config_file:+--config "$config_file"} --connect-socket $DAEMON_SOCKET
|