Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions kalamine/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def load_descriptor(file_path: Path) -> Dict:
cfg = load_descriptor(layout_path)
if "name" not in cfg:
cfg["name"] = layout_path.stem
if not "xkb_label":
cfg["xkb_label"] = ""
if "extends" in cfg:
parent_path = layout_path.parent / cfg["extends"]
ext = load_descriptor(parent_path)
Expand Down Expand Up @@ -77,6 +79,7 @@ class MetaDescr:
locale: str = "us"
geometry: str = "ISO"
description: str = ""
xkb_label: str = ""
author: str = "nobody"
license: str = ""
version: str = "0.0.1"
Expand All @@ -96,6 +99,7 @@ class SpacebarDescr:
"author": "nobody",
"license": "WTFPL - Do What The Fuck You Want Public License",
"geometry": "ISO",
"xkb_label": "",
}

SPACEBAR = {
Expand Down
10 changes: 8 additions & 2 deletions kalamine/xkb_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,12 +370,17 @@ def remove_rules_variant(variant_list: ET.Element, name: str) -> None:
variant_list.remove(variant)


def add_rules_variant(variant_list: ET.Element, name: str, description: str) -> None:
def add_rules_variant(variant_list: ET.Element, name: str, description: str, xkb_label: str) -> None:
"""Add a <variant/configItem/{name,description> item to <layout/variantList>."""

variant = ET.SubElement(variant_list, "variant")
config = ET.SubElement(variant, "configItem")
ET.SubElement(config, "name").text = name
if xkb_label != "":
# Set the label used notably by Fcitx5 in the systray, see:
# https://github.com/fcitx/fcitx5/issues/1555
# Note: `shortDescription` MUST appear before `description` for the document to be valid
ET.SubElement(config, "shortDescription").text = xkb_label
ET.SubElement(config, "description").text = description


Expand All @@ -399,7 +404,8 @@ def update_rules(xkb_root: Path, kbd_index: KbdIndex) -> None:
remove_rules_variant(vlist, name)
if layout is not None:
description = layout.meta["description"]
add_rules_variant(vlist, name, description)
xkb_label = layout.meta["xkb_label"]
add_rules_variant(vlist, name, description, xkb_label)

ET.indent(tree)

Expand Down
Loading