Commit bd8c427d authored by Ian Beckwith's avatar Ian Beckwith

Implemented XDG basedir spec for local config

(http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html)
Local config is searched for in:
  * $SURFRAW_conf if defined
  * $XDG_CONFIG_HOME/surfraw/conf
  * $HOME/.config/surfraw/conf
  * $HOME/.surfraw.conf (for backwards compatibility)
Removed definition of SURFRAW_conf from global config
parent 3e4591d8
...@@ -50,13 +50,35 @@ load_global_conf () { ...@@ -50,13 +50,35 @@ load_global_conf () {
. "$conf" . "$conf"
} }
w3_config () { find_config_file () {
prefix=@prefix@ base="$1"
def SURFRAW_conf $HOME/.surfraw.conf if test -n "$XDG_CONFIG_HOME" && test -r "$XDG_CONFIG_HOME/surfraw/$base"; then
echo "$XDG_CONFIG_HOME/surfraw/$base"
elif test -n "$HOME" && test -r "$HOME/.config/surfraw/$base"; then
echo "$HOME/.config/surfraw/$base"
elif test -r "$HOME/.surfraw.$base"; then
echo "$HOME/.surfraw.$base"
fi
}
load_local_conf () {
local conf
conf=""
if test -n "$SURFRAW_conf" && test -r "$SURFRAW_conf"; then
conf="$SURFRAW_conf"
else
conf="$(find_config_file conf)"
fi
if test -n "$conf"; then
. $conf
fi
}
w3_config () {
load_global_conf load_global_conf
w3_config_hook w3_config_hook
test -r "$SURFRAW_conf" && . "$SURFRAW_conf" load_local_conf
} }
warn () { warn () {
......
...@@ -26,9 +26,6 @@ ...@@ -26,9 +26,6 @@
# autoconf guessed prefix # autoconf guessed prefix
prefix=@prefix@ prefix=@prefix@
# secondary configuation file
def SURFRAW_conf $HOME/.surfraw.conf
# graphical browser? defaults to yes for meatminds. text browser users can # graphical browser? defaults to yes for meatminds. text browser users can
# work it out how to change it. # work it out how to change it.
defyn SURFRAW_graphical yes defyn SURFRAW_graphical yes
......
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