XDG Support
authorJack Miller <jack@codezen.org>
Wed, 24 Jun 2015 21:04:31 +0000 (16:04 -0500)
committerJack Miller <jack@codezen.org>
Wed, 24 Jun 2015 21:04:31 +0000 (16:04 -0500)
- If it exists, will still use ~/.canto-ng

- Respects $XDG_CONFIG_HOME, but will throw everything in there (won't
  use $XDG_DATA_HOME for feeds/logs)

- canto is the directory name, not canto-ng so ~/.config/canto is likely
  the new directory

canto_next/protocol.py

index d1f4d25..fe8f627 100644 (file)
@@ -70,7 +70,18 @@ class CantoSocket:
             log.error("Error: %s" % e.msg)
             return -1
 
-        self.conf_dir = os.path.expanduser("~/.canto-ng/")
+        old_path = os.path.expanduser("~/.canto-ng")
+
+        if os.path.exists(old_path):
+            self.conf_dir = old_path
+        else:
+            if "XDG_CONFIG_HOME" in os.environ:
+                xdg_path = os.environ["XDG_CONFIG_HOME"]
+            else:
+                xdg_path = "~/.config"
+
+            xdg_path = os.path.expanduser(xdg_path)
+            self.conf_dir = xdg_path + "/canto"
 
         self.location_args = []