1
0
Fork 0
mirror of synced 2024-05-18 19:42:54 +12:00

RareCore: Check if LEGENDARY_CONFIG_PATH is set before creating a new config

This commit is contained in:
loathingKernel 2023-12-16 00:39:00 +02:00
parent 097b76fc6b
commit c3bdffcd50
No known key found for this signature in database
GPG key ID: CE0C72D0B53821FD

View file

@ -133,10 +133,12 @@ class RareCore(QObject):
self.__core = LegendaryCore()
except configparser.MissingSectionHeaderError as e:
logger.warning(f"Config is corrupt: {e}")
if config_path := os.environ.get("XDG_CONFIG_HOME"):
path = os.path.join(config_path, "legendary")
if config_path := os.environ.get('LEGENDARY_CONFIG_PATH'):
path = config_path
elif config_path := os.environ.get('XDG_CONFIG_HOME'):
path = os.path.join(config_path, 'legendary')
else:
path = os.path.expanduser("~/.config/legendary")
path = os.path.expanduser('~/.config/legendary')
with open(os.path.join(path, "config.ini"), "w") as config_file:
config_file.write("[Legendary]")
self.__core = LegendaryCore()