Skip to content

feat(keyboard-layout): custom labels support (v5 port)#2925

Open
fennstef wants to merge 4 commits into
noctalia-dev:v5from
fennstef:feat/keyboard-layout-custom-labels-v5
Open

feat(keyboard-layout): custom labels support (v5 port)#2925
fennstef wants to merge 4 commits into
noctalia-dev:v5from
fennstef:feat/keyboard-layout-custom-labels-v5

Conversation

@fennstef
Copy link
Copy Markdown

@fennstef fennstef commented Jun 6, 2026

Summary

Port of the keyboard layout custom labels feature from v4 to v5.

  • DisplayMode::Custom: New display mode that shows a user-defined label for each layout. Falls back to the layout name if no mapping is configured.
  • custom_labels config key: TOML sub-table under [widget.keyboard_layout] mapping layout names to display labels:
    [widget.keyboard_layout]
    display = "custom"
    [widget.keyboard_layout.custom_labels]
    de = "DE"
    us = "EN"
  • Settings GUI: All keyboard layout settings are now exposed in the widget inspector (cycle_command, hide_when_single_layout, show_icon, show_label, display, custom_labels). The custom_labels editor pre-populates rows for all currently active compositor layouts.
  • OSD pill: The layout-change notification pill also uses custom labels.

Implementation notes

custom_labels is a string→string map. Because toml++ statically introspects the WidgetSettingValue variant and rejects non-native TOML types, the map cannot be added to that variant. Instead, a separate tables field (unordered_map<string, unordered_map<string,string>>) was added to WidgetConfig to hold TOML sub-tables. Override persistence works via widgetConfigEqual which now compares tables as well.

Test plan

  • Set display = "custom" in widget inspector, verify segmented control shows short/full/custom
  • Active layout names appear pre-populated in the custom labels editor
  • Enter a label, press Enter → verify saved in ~/.local/state/noctalia/settings.toml
  • Close and reopen settings → labels still present
  • Switch keyboard layout → OSD pill shows custom label
  • With no custom label set for a layout → OSD falls back to display mode formatting

Stefan Fenn added 4 commits June 6, 2026 22:30
Allows users to override the auto-generated short label for any keyboard
layout by name via the [widget.keyboard_layout.custom_labels] TOML table:

  [widget.keyboard_layout.custom_labels]
  "German (Neo 2)" = "Neo2"
  "English (US)"   = "EN"

To support TOML sub-tables as widget settings, WidgetSettingValue gains
a new unordered_map<string,string> variant. readWidgetSettingValue parses
inline and dotted tables into this type; WidgetConfig.getStringMap()
retrieves it. All existing std::visit call-sites are updated to handle
the new variant (config_export, bar_widget_editor, scripted_widget_bindings).
…conflict

toml++ uses template introspection on WidgetSettingValue and rejects
unordered_map as a variant member. Instead, TOML tables are parsed into
WidgetConfig::tables (separate from settings) and getStringMap reads from
there. config_export round-trips tables back to TOML correctly.
- Add all keyboard layout settings to the settings panel (cycle_command,
  hide_when_single_layout, show_icon, show_label, display, custom_labels)
- Add DisplayMode::Custom for direct custom-label-only display
- Add KeyValueMap control type for editing string→string mappings in GUI
- Pre-populate custom_labels editor with active compositor layout names
- Apply custom labels in the OSD pill shown on layout change
- Store TOML sub-tables in a separate `tables` field on WidgetConfig to
  avoid toml++ variant type constraints
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant