From: Fabio Fantoni Date: Fri, 17 Jul 2026 20:39:54 +0200 Subject: keyboard: fall back to tecla for layout preview where libgnomekbd is unavailable gkbd-keyboard-display comes from libgnomekbd, which is unmaintained and being removed from distributions (GNOME replaced it with tecla in 45, Debian is dropping libgnomekbd). It is also an X11-only GTK3 program, so the layout preview was already unavailable under Wayland. cinnamon-settings already hid the layout preview button (in the "Add layout" dialog) and the "Test layout" button when gkbd-keyboard-display was missing, silently dropping the feature. Fall back to tecla when gkbd-keyboard-display is not installed, and hide the buttons only when neither program is available. gkbd-keyboard-display stays preferred where present, since tecla only renders a standard pc105 geometry (this addresses the TODO removed from InputSources.py). As tecla is a GTK4 program it also works under Wayland, restoring the preview there. tecla is invoked with a single "layout+variant" argument: '+' is accepted as the layout/variant separator by every tecla version (space and tab only since tecla 48), so it is used unconditionally. The keyboard applet added its "Show Keyboard Layout" menu entry unconditionally, so with no preview program installed clicking it only produced an "Execution of 'gkbd-keyboard-display' failed" error notification. It now uses the same lookup and fallback, and the entry is hidden when no preview program is available. Assisted-by: Claude Code:claude-opus-4-8 Forwarded: https://github.com/linuxmint/cinnamon/pull/13878 Bug-Debian: https://bugs.debian.org/1123771 --- .../applets/keyboard@cinnamon.org/applet.js | 33 ++++++++++++++++++---- .../cinnamon-settings/bin/AddKeyboardLayout.py | 24 ++++++++++++---- .../cinnamon/cinnamon-settings/bin/InputSources.py | 6 ++-- 3 files changed, 47 insertions(+), 16 deletions(-) diff --git a/files/usr/share/cinnamon/applets/keyboard@cinnamon.org/applet.js b/files/usr/share/cinnamon/applets/keyboard@cinnamon.org/applet.js index e576251..37ccee6 100644 --- a/files/usr/share/cinnamon/applets/keyboard@cinnamon.org/applet.js +++ b/files/usr/share/cinnamon/applets/keyboard@cinnamon.org/applet.js @@ -4,6 +4,7 @@ const Main = imports.ui.main; const PopupMenu = imports.ui.popupMenu; const Util = imports.misc.util; const Gio = imports.gi.Gio; +const GLib = imports.gi.GLib; const Signals = imports.signals; const KeyboardManager = imports.ui.keyboardManager; const IBus = imports.gi.IBus; @@ -77,7 +78,9 @@ class CinnamonKeyboardApplet extends Applet.Applet { this._propSection = new PopupMenu.PopupMenuSection(); this.menu.addMenuItem(this._propSection); this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); - this.showLayoutAction = this.menu.addAction(_("Show Keyboard Layout"), () => this._showActiveLayout()); + this.showLayoutAction = null; + if (this._getLayoutDisplayProgram() !== null) + this.showLayoutAction = this.menu.addAction(_("Show Keyboard Layout"), () => this._showActiveLayout()); this.menu.addAction(_("Show Character Table"), () => { Main.overview.hide(); Util.spawn(['gucharmap']); @@ -95,16 +98,33 @@ class CinnamonKeyboardApplet extends Applet.Applet { } } + _getLayoutDisplayProgram() { + // tecla only shows a standard pc105 geometry, keep gkbd-keyboard-display + // (libgnomekbd) preferred where still available. + for (const program of ['gkbd-keyboard-display', 'tecla']) { + if (GLib.find_program_in_path(program)) + return program; + } + return null; + } + _showActiveLayout() { Main.overview.hide(); let source = this._inputSourcesManager.currentSource; let description = source.xkbLayout; - if (source.variant.length > 0) - description = '%s\t%s'.format(description, source.variant); - - Util.spawn(['gkbd-keyboard-display', '-l', description]); + if (this._getLayoutDisplayProgram() === 'tecla') { + // '+' is the layout/variant separator accepted by every tecla + // version (space and tab only since tecla 48) + if (source.variant.length > 0) + description = '%s+%s'.format(description, source.variant); + Util.spawn(['tecla', description]); + } else { + if (source.variant.length > 0) + description = '%s\t%s'.format(description, source.variant); + Util.spawn(['gkbd-keyboard-display', '-l', description]); + } } _onCurrentSourceChanged() { @@ -219,7 +239,8 @@ class CinnamonKeyboardApplet extends Applet.Applet { this.actor.hide(); } - this.showLayoutAction.setSensitive(selected.type === 'xkb'); + if (this.showLayoutAction !== null) + this.showLayoutAction.setSensitive(selected.type === 'xkb'); this._updatePropertySection(selected.properties); } diff --git a/files/usr/share/cinnamon/cinnamon-settings/bin/AddKeyboardLayout.py b/files/usr/share/cinnamon/cinnamon-settings/bin/AddKeyboardLayout.py index baca365..ea30638 100644 --- a/files/usr/share/cinnamon/cinnamon-settings/bin/AddKeyboardLayout.py +++ b/files/usr/share/cinnamon/cinnamon-settings/bin/AddKeyboardLayout.py @@ -21,11 +21,23 @@ MAX_LAYOUTS_PER_GROUP = 4 INPUT_SOURCE_SETTINGS = "org.cinnamon.desktop.input-sources" SHOW_ALL_SOURCES_KEY="show-all-sources" -def make_gkbd_keyboard_args(layout, variant): +def get_layout_preview_program(): + # tecla only shows a standard pc105 geometry, keep gkbd-keyboard-display + # (libgnomekbd) preferred where still available. + for program in ("gkbd-keyboard-display", "tecla"): + if GLib.find_program_in_path(program): + return program + return None + +def make_layout_preview_args(layout, variant): + program = get_layout_preview_program() + if program == "tecla": + # '+' is the layout/variant separator accepted by every tecla version + # (space and tab only since tecla 48) + return [program, f"{layout}+{variant}" if variant else layout] if variant: - return ["gkbd-keyboard-display", "-l", f"{layout}\t{variant}"] - else: - return ["gkbd-keyboard-display", "-l", layout] + return [program, "-l", f"{layout}\t{variant}"] + return [program, "-l", layout] def make_ibus_display_name(engine): name = engine.get_longname() @@ -93,7 +105,7 @@ class AddKeyboardLayoutDialog(): self.response_id = None - if not GLib.find_program_in_path("gkbd-keyboard-display"): + if get_layout_preview_program() is None: self.preview_button.set_visible(False) self._ibus = IBus.Bus.new_async() @@ -157,7 +169,7 @@ class AddKeyboardLayoutDialog(): display_name = self.layouts_sort_store.get_value(iter, LAYOUT_DISPLAY_NAME_COLUMN) layout_layout = self.layouts_sort_store.get_value(iter, LAYOUT_LAYOUT_COLUMN) layout_variant = self.layouts_sort_store.get_value(iter, LAYOUT_VARIANT_COLUMN) - args = make_gkbd_keyboard_args(layout_layout, layout_variant) + args = make_layout_preview_args(layout_layout, layout_variant) subprocess.Popen(args) def _on_all_sources_changed(self, button, data=None): diff --git a/files/usr/share/cinnamon/cinnamon-settings/bin/InputSources.py b/files/usr/share/cinnamon/cinnamon-settings/bin/InputSources.py index c0c2d06..a17d2b4 100644 --- a/files/usr/share/cinnamon/cinnamon-settings/bin/InputSources.py +++ b/files/usr/share/cinnamon/cinnamon-settings/bin/InputSources.py @@ -38,9 +38,7 @@ class InputSourceSettingsPage(SettingsPage): self.test_layout_button = builder.get_object("test_layout") self.test_layout_button.connect("clicked", self.on_test_layout_clicked) - # TODO: maybe use tecla as an alternative for wayland, if we don't roll something ourselves. - # btw there's no plan for tecla to support different keyboard geometries than a standard pc105. - if not GLib.find_program_in_path("gkbd-keyboard-display"): + if AddKeyboardLayout.get_layout_preview_program() is None: self.test_layout_button.set_visible(False) self.engine_config_button = builder.get_object("engine_config_button") @@ -173,7 +171,7 @@ class InputSourceSettingsPage(SettingsPage): def on_test_layout_clicked(self, button, data=None): source = self._get_selected_source() - args = AddKeyboardLayout.make_gkbd_keyboard_args(source.xkb_layout, source.xkb_variant) + args = AddKeyboardLayout.make_layout_preview_args(source.xkb_layout, source.xkb_variant) subprocess.Popen(args) def on_engine_config_clicked(self, button, data=None):