Commit 3e4591d8 authored by Ian Beckwith's avatar Ian Beckwith

Implemented XDG basedir spec for global config

(http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html)
Looks for global config file in:
  * SURFRAW_global_conf if set
  * surfraw/conf under each dir in (colon separated) $XDG_CONFIG_DIRS.
  * @[email protected]/xdg/surfraw/conf
  * @[email protected]/surfraw.conf (for backwards compatibility)
parent f0e14657
......@@ -22,13 +22,39 @@ w3_config_hook () {
return 1
}
load_global_conf () {
local conf OIFS
conf=""
# if explicitly specified
if test -n "$SURFRAW_global_conf" && test -r "$SURFRAW_global_conf"; then
conf="$SURFRAW_global_conf"
elif test -n "$XDG_CONFIG_DIRS"; then
OIFS="$IFS"
IFS=:
set $XDG_CONFIG_DIRS
IFS="$OIFS"
for i in "[email protected]"; do
if test -r "$i/surfraw/conf"; then
conf="$i/surfraw/conf"
break
fi
done
elif test -r "@[email protected]/xdg/surfraw/conf"; then # XDG default
conf="@[email protected]/xdg/surfraw/conf"
elif test -r "@[email protected]/surfraw.conf"; then # old surfraw default
conf="@[email protected]/surfraw.conf"
fi
if test -z "$conf"; then
err "couldn't find global config in @[email protected]/xdg/surfraw/conf or \$XDG_CONFIG_DIRS"
fi
. "$conf"
}
w3_config () {
prefix=@[email protected]
def SURFRAW_global_conf @[email protected]/surfraw.conf
def SURFRAW_conf $HOME/.surfraw.conf
test -r "$SURFRAW_global_conf" || err "couldn't source SURFRAW_global_conf ($SURFRAW_global_conf)"
. "$SURFRAW_global_conf"
load_global_conf
w3_config_hook
test -r "$SURFRAW_conf" && . "$SURFRAW_conf"
}
......
......@@ -26,9 +26,6 @@
# autoconf guessed prefix
[email protected]@
# setting this here is of dubious utility
def SURFRAW_global_conf @[email protected]/surfraw.conf
# secondary configuation file
def SURFRAW_conf $HOME/.surfraw.conf
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment