From 4c7042da56c17179f3260ccceed290528b269c48 Mon Sep 17 00:00:00 2001 From: Hugo Osvaldo Barrera Date: Sun, 14 Dec 2014 17:45:48 -0300 Subject: [PATCH 1/3] Use XDG-Basedir as a fallback for configuration file location. --- vdirsyncer/cli.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vdirsyncer/cli.py b/vdirsyncer/cli.py index 2847317..737f52d 100644 --- a/vdirsyncer/cli.py +++ b/vdirsyncer/cli.py @@ -273,6 +273,10 @@ def _create_app(): if 'config' not in ctx.obj: fname = expand_path(os.environ.get('VDIRSYNCER_CONFIG', '~/.vdirsyncer/config')) + if not os.path.exists(fname): + xdg_config_dir = os.environ.get('XDG_CONFIG_HOME', + expand_path('~/.config/')) + fname = os.path.join(xdg_config_dir, 'vdirsyncer/config') try: ctx.obj['config'] = load_config(fname) except Exception as e: From ff72e3482648af97539825489aa030ff36391813 Mon Sep 17 00:00:00 2001 From: Hugo Osvaldo Barrera Date: Sun, 14 Dec 2014 17:57:13 -0300 Subject: [PATCH 2/3] Document XDG-Basedir compatibility. Document that it's possible to place the configuration file in and XDG-Basedir compliant location. --- README.rst | 4 +++- docs/tutorial.rst | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 803716c..3d37709 100644 --- a/README.rst +++ b/README.rst @@ -21,7 +21,9 @@ Installation and usage ====================== If you already have it installed and want to quickly configure it, copy the -``example.cfg`` to ``~/.vdirsyncer/config`` and edit it. +``example.cfg`` to ``$XDG_CONFIG_HOME/vdirsyncer/config`` (normally +``~/.config/vdirsyncer/config``) +and edit it. If that method doesn't work for you or you want a deeper understanding of what you just did, check out `the tutorial diff --git a/docs/tutorial.rst b/docs/tutorial.rst index 584feb5..1011a23 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -34,8 +34,9 @@ Configuration planned. By default, *vdirsyncer* looks for its configuration file at -``~/.vdirsyncer/config``. You can use the ``VDIRSYNCER_CONFIG`` environment -variable to change this path. +``$XDG_CONFIG_HOME/vdirsyncer/config`` (normally +``~/.config/vdirsyncer/config``) and ``~/.vdirsyncer/config``. You can use the +``VDIRSYNCER_CONFIG`` environment variable to change this path. The config file should start with a :ref:`general section `, where the only required parameter is ``status_path``. The following is a From 41a92528caab1f1a71c28e22c96c6f2f912a0f06 Mon Sep 17 00:00:00 2001 From: Hugo Osvaldo Barrera Date: Mon, 15 Dec 2014 15:51:35 -0300 Subject: [PATCH 3/3] Update doc as per latest feedback. --- README.rst | 6 +++--- docs/tutorial.rst | 12 ++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.rst b/README.rst index 3d37709..a28bf3d 100644 --- a/README.rst +++ b/README.rst @@ -21,14 +21,14 @@ Installation and usage ====================== If you already have it installed and want to quickly configure it, copy the -``example.cfg`` to ``$XDG_CONFIG_HOME/vdirsyncer/config`` (normally -``~/.config/vdirsyncer/config``) -and edit it. +``example.cfg`` to ``~/.vdirsyncer/config`` [1]_ and edit it. If that method doesn't work for you or you want a deeper understanding of what you just did, check out `the tutorial `_. +.. [1] The configuration file can also be placed in ``$XDG_CONFIG_HOME/vdirsyncer/config`` (normally ``~/.config/vdirsyncer/config``) for XDG-Basedir spec compliance. + Donations ========= diff --git a/docs/tutorial.rst b/docs/tutorial.rst index 1011a23..aae6a5f 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -33,10 +33,14 @@ Configuration - Take a look at the :doc:`problems` page if anything doesn't work like planned. -By default, *vdirsyncer* looks for its configuration file at -``$XDG_CONFIG_HOME/vdirsyncer/config`` (normally -``~/.config/vdirsyncer/config``) and ``~/.vdirsyncer/config``. You can use the -``VDIRSYNCER_CONFIG`` environment variable to change this path. +By default, *vdirsyncer* looks for its configuration file in the following +locations: + +- The file pointed to by the ``VDIRSYNCER_CONFIG`` environment variable. +- ``~/.vdirsyncer/config``. +- ``$XDG_CONFIG_HOME/vdirsyncer/config``, which is normally + ``~/.config/vdirsyncer/config``. This is XDG-Basedir compliant, and should + help keep your ``$HOME`` clean. The config file should start with a :ref:`general section `, where the only required parameter is ``status_path``. The following is a