diff --git a/docs/Configuration.md b/docs/Configuration.md index a1f321b8..47372c8f 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -192,7 +192,8 @@ KlipperScreen will search for a configuration file in the following order: 1. _~/KlipperScreen.conf_ 2. _${KlipperScreen_Directory}/KlipperScreen.conf_ -3. _~/klipper_config/KlipperScreen.conf_ +3. _~/printer_data/config/KlipperScreen.conf_ +4. _~/klipper_config/KlipperScreen.conf_ If you need a custom location for the configuration file, you can add -c or --configfile to the systemd file and specify the location of your configuration file. diff --git a/ks_includes/config.py b/ks_includes/config.py index cf7ad8c4..d1613efb 100644 --- a/ks_includes/config.py +++ b/ks_includes/config.py @@ -348,21 +348,36 @@ class KlipperScreenConfig: return ["\n".join(user_def), None if saved_def is None else "\n".join(saved_def)] def get_config_file_location(self, file): - logging.info(f"Passed config file: {file}") - if not path.exists(file): - file = os.path.join(klipperscreendir, self.configfile_name) - if not path.exists(file): - file = self.configfile_name.lower() - if not path.exists(file): - klipper_config = os.path.join(os.path.expanduser("~/"), "klipper_config") - file = os.path.join(klipper_config, self.configfile_name) - if not path.exists(file): - file = os.path.join(klipper_config, self.configfile_name.lower()) - if not path.exists(file): - file = self.default_config_path + # Passed config (-c) by default is ~/KlipperScreen.conf + if path.exists(file): + return file - logging.info(f"Found configuration file at: {file}") - return file + file = os.path.join(klipperscreendir, self.configfile_name) + if path.exists(file): + return file + file = os.path.join(klipperscreendir, self.configfile_name.lower()) + if path.exists(file): + return file + + klipper_config = os.path.join(os.path.expanduser("~/"), "printer_data", "config") + file = os.path.join(klipper_config, self.configfile_name) + if path.exists(file): + return file + file = os.path.join(klipper_config, self.configfile_name.lower()) + if path.exists(file): + return file + + # OLD config folder + klipper_config = os.path.join(os.path.expanduser("~/"), "klipper_config") + file = os.path.join(klipper_config, self.configfile_name) + if path.exists(file): + return file + file = os.path.join(klipper_config, self.configfile_name.lower()) + if path.exists(file): + return file + + # fallback + return self.default_config_path def get_config(self): return self.config