From 1af42e6f0f1ca2fa51009e99badbedd1173fe2e8 Mon Sep 17 00:00:00 2001 From: Jesper Hansen Date: Wed, 16 Mar 2022 00:14:36 +0100 Subject: [PATCH] Added option to select default printer at startup. (#542) --- docs/Configuration.md | 3 +++ screen.py | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/Configuration.md b/docs/Configuration.md index fee52abe..893c144e 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -36,6 +36,9 @@ show_cursor: False # Allows to define custom systemctl command for restart like xrdp service: KlipperScreen + +# If multiple printers are defined, this can be set the name of the one to show at startup. +default_printer: Ender 3 Pro ``` ## Printer Options diff --git a/screen.py b/screen.py index 57a118e8..813b634c 100644 --- a/screen.py +++ b/screen.py @@ -143,9 +143,12 @@ class KlipperScreen(Gtk.Window): self.change_cursor() printers = self._config.get_printers() - logging.debug("Printers: %s" % printers) - if len(printers) == 1: - pname = list(self._config.get_printers()[0])[0] + default_printer = self._config.get_main_config().get('default_printer') + logging.debug("Printers: %s, Default: %s" % (printers, default_printer)) + if [True for p in printers if default_printer in p]: + self.connect_printer(default_printer) + elif len(printers) == 1: + pname = list(printers[0])[0] self.connect_printer(pname) else: self.show_panel("printer_select", "printer_select", "Printer Select", 2)