From 71a32e9fa086fb16f92d380a1f88d38cbccf36bf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Apitzsch?= <git@apitzsch.eu>
Date: Fri, 10 Apr 2020 22:48:58 +0200
Subject: [PATCH] Config: Simplify base directory handling

---
 gajim/common/configpaths.py | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/gajim/common/configpaths.py b/gajim/common/configpaths.py
index cbd65b7bd2..5809cd31d0 100644
--- a/gajim/common/configpaths.py
+++ b/gajim/common/configpaths.py
@@ -30,6 +30,8 @@
 import tempfile
 from pathlib import Path
 
+from gi.repository import GLib
+
 import gajim
 from gajim.common.i18n import _
 from gajim.common.const import PathType, PathLocation
@@ -114,19 +116,10 @@ def __init__(self) -> None:
                 # win9x, in cwd
                 self.config_root = self.cache_root = self.data_root = '.'
         else:
-            expand = os.path.expanduser
-            base = os.getenv('XDG_CONFIG_HOME')
-            if base is None or base[0] != '/':
-                base = expand('~/.config')
-            self.config_root = os.path.join(base, 'gajim')
-            base = os.getenv('XDG_CACHE_HOME')
-            if base is None or base[0] != '/':
-                base = expand('~/.cache')
-            self.cache_root = os.path.join(base, 'gajim')
-            base = os.getenv('XDG_DATA_HOME')
-            if base is None or base[0] != '/':
-                base = expand('~/.local/share')
-            self.data_root = os.path.join(base, 'gajim')
+            self.config_root = os.path.join(GLib.get_user_config_dir(),
+                                            'gajim')
+            self.cache_root = os.path.join(GLib.get_user_cache_dir(), 'gajim')
+            self.data_root = os.path.join(GLib.get_user_data_dir(), 'gajim')
 
         import pkg_resources
         basedir = pkg_resources.resource_filename("gajim", ".")
-- 
GitLab