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.
  * @sysconfigdir@/xdg/surfraw/conf
  * @sysconfigdir@/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 "$@"; do
if test -r "$i/surfraw/conf"; then
conf="$i/surfraw/conf"
break
fi
done
elif test -r "@sysconfdir@/xdg/surfraw/conf"; then # XDG default
conf="@sysconfdir@/xdg/surfraw/conf"
elif test -r "@sysconfdir@/surfraw.conf"; then # old surfraw default
conf="@sysconfdir@/surfraw.conf"
fi
if test -z "$conf"; then
err "couldn't find global config in @sysconfdir@/xdg/surfraw/conf or \$XDG_CONFIG_DIRS"
fi
. "$conf"
}
w3_config () {
prefix=@prefix@
def SURFRAW_global_conf @sysconfdir@/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
prefix=@prefix@
# setting this here is of dubious utility
def SURFRAW_global_conf @sysconfdir@/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