diff --git a/core/app.py b/core/app.py index c26eae7..3930ce7 100644 --- a/core/app.py +++ b/core/app.py @@ -4,7 +4,11 @@ import os import sys import re -import xdg.BaseDirectory + +try: + import xdg.BaseDirectory as xdg_bd +except: + xdg_bd = None from . import file from . import text @@ -237,11 +241,18 @@ class Main: self.help_texts = [] # (chapter, [paragraphs]) self.print = text.Output(self.name + '.main') - self.data_dir = os.path.join(xdg.BaseDirectory.xdg_data_home, self.name) + if xdg_bd: + xdg_data = xdg_bd.xdg_data_home + xdg_config = xdg_bd.xdg_config_home + else: + xdg_data = os.path.expanduser('~/.local/share') + xdg_config = os.path.expanduser('~/.config') + + self.data_dir = os.path.join(xdg_data, self.name) file.File(os.path.join(self.data_dir, '.keep')) if use_cfg_file: - self.cfg_file = file.File(os.path.join(xdg.BaseDirectory.xdg_config_home, self.name, 'main.cfg'), encoding='utf-8') + self.cfg_file = file.File(os.path.join(xdg_config, self.name, 'main.cfg'), encoding='utf-8') if not self.cfg_file.data: self.cfg_file.data = '''# Configuration file for %s