Skip to content

Commit 9fbe6b2

Browse files
committed
added ability to change layout of emulated keyboard, for example colemak
1 parent abcd919 commit 9fbe6b2

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

linux/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ distribution corresponding packages):
88
- Treal support: `libusb` (1.0) and `libudev` are needed by
99
the [`hidapi` package](https://pypi.org/project/hidapi/).
1010
- log / notifications support: `libdbus` is needed.
11-
- Uinput support: `libxkbcommon` are needed by the [`xkbcommon` package](https://pypi.org/project/xkbcommon)
11+
- Uinput support: `libxkbcommon` is needed by the [`xkbcommon` package](https://pypi.org/project/xkbcommon)
1212

1313
For the rest of the steps, follow the [developer guide](../doc/developer_guide.md).

plover/gui_qt/config_window.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,8 @@ def __init__(self, engine):
410410
'\n'
411411
'This only applies when using Linux/BSD and not using X11.\n'
412412
'If you\'re unsure, you probably don\'t need to change it.\n'
413-
'If you need to configure more options about your layout,\n'
414-
'such as setting the variant to a different layout like colemak,\n'
415-
'you can set environment variables starting with XKB_DEFAULT_\n'
416-
'for the RULES, MODEL, VARIANT and OPTIONS')),
413+
'If you use a different layout variant, format it as\n'
414+
'"language:layout", for example "us:colemak"')),
417415
)),
418416
# i18n: Widget: “ConfigWindow”.
419417
(_('Plugins'), (

plover/oslayer/linux/keyboardcontrol_uinput.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,13 @@ def __init__(self):
173173
self._res = util.find_ecodes_by_regex(r"KEY_.*")
174174
self._ui = UInput(self._res)
175175

176-
def _update_layout(self, layout):
177-
log.info("Using keyboard layout " + layout + " for keyboard emulation.")
178-
symbols = generate_symbols(layout)
176+
def _update_layout(self, _layout):
177+
log.info("Using keyboard layout " +
178+
_layout + " for keyboard emulation.")
179+
_layout_options = _layout.split(":")
180+
layout = _layout_options[0]
181+
variant = _layout_options[1] if len(_layout_options) > 1 else ""
182+
symbols = generate_symbols(layout, variant)
179183
# Remove symbols not in KEY_TO_KEYCODE
180184
syms_to_remove = []
181185
for sym in symbols:

plover/oslayer/linux/xkb_symbols.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99

1010
# layout can be "no", "us", "gb", "fr" or any other xkb layout
11-
def generate_symbols(layout="us"):
11+
def generate_symbols(layout="us", variant = ""):
1212
ctx = xkb.Context()
13-
keymap = ctx.keymap_new_from_names(layout=layout)
13+
keymap = ctx.keymap_new_from_names(layout=layout, variant=variant)
1414
# The keymaps have to be "translated" to a US layout keyboard for evdev
1515
keymap_us = ctx.keymap_new_from_names(layout="us")
1616

0 commit comments

Comments
 (0)