config: add printer_data to default config search locations

close #759
This commit is contained in:
alfrix 2022-10-21 10:29:31 -03:00
parent 2121d4a6aa
commit c5413e51c9
2 changed files with 31 additions and 15 deletions

View File

@ -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.

View File

@ -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