Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix CLI layout args overriding keymap ones #159

Merged
merged 2 commits into from
Feb 24, 2025
Merged
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
24 changes: 16 additions & 8 deletions keymap_drawer/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,24 @@ def draw(args: Namespace, config: Config) -> None:
assert "layers" in yaml_data, 'Keymap needs to be specified via the "layers" field in keymap_yaml'

cli_layout = {
"qmk_keyboard": args.qmk_keyboard,
"zmk_keyboard": args.zmk_keyboard,
"qmk_info_json": args.qmk_info_json,
"dts_layout": args.dts_layout,
"layout_name": args.layout_name,
"ortho_layout": args.ortho_layout,
"cols_thumbs_notation": args.cols_thumbs_notation,
k: v
for k, v in (
("qmk_keyboard", args.qmk_keyboard),
("zmk_keyboard", args.zmk_keyboard),
("qmk_info_json", args.qmk_info_json),
("dts_layout", args.dts_layout),
("ortho_layout", args.ortho_layout),
("cols_thumbs_notation", args.cols_thumbs_notation),
)
if v is not None
}
keymap_layout = yaml_data.get("layout", {})
layout = keymap_layout | {k: v for k, v in cli_layout.items() if v is not None}

layout = {"layout_name": keymap_layout.get("layout_name")} | cli_layout if cli_layout else keymap_layout
if args.layout_name:
layout["layout_name"] = args.layout_name

logger.debug("final physical layout spec for draw: %s", layout)

assert layout, (
"A physical layout needs to be specified either via "
Expand Down
4 changes: 4 additions & 0 deletions keymap_drawer/physical_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ def handle_qmk_layout(self):
logger.warning('"qmk_layout" is deprecated, please use "layout_name" instead')
assert self.layout_name is None, '"qmk_layout" cannot be used with "layout_name", use the latter'
self.layout_name = self.qmk_layout
if self.layout_name is not None and (self.ortho_layout is not None or self.cols_thumbs_notation is not None):
logger.warning(
'"layout_name" cannot be used with "ortho_layout" or "cols_thumbs_notation", will be ignored'
)
return self

def generate(self) -> PhysicalLayout:
Expand Down