Added option to select default printer at startup. (#542)

This commit is contained in:
Jesper Hansen 2022-03-16 00:14:36 +01:00 committed by GitHub
parent aa6ae014d8
commit 1af42e6f0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -36,6 +36,9 @@ show_cursor: False
# Allows to define custom systemctl command for restart like xrdp # Allows to define custom systemctl command for restart like xrdp
service: KlipperScreen 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 ## Printer Options

View File

@ -143,9 +143,12 @@ class KlipperScreen(Gtk.Window):
self.change_cursor() self.change_cursor()
printers = self._config.get_printers() printers = self._config.get_printers()
logging.debug("Printers: %s" % printers) default_printer = self._config.get_main_config().get('default_printer')
if len(printers) == 1: logging.debug("Printers: %s, Default: %s" % (printers, default_printer))
pname = list(self._config.get_printers()[0])[0] 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) self.connect_printer(pname)
else: else:
self.show_panel("printer_select", "printer_select", "Printer Select", 2) self.show_panel("printer_select", "printer_select", "Printer Select", 2)