a cross-platform Keyboard Layout Maker
Project description
A text-based, cross-platform Keyboard Layout Maker.
Install
All you need is a Python environment:
pip install kalamine
If you get a UnicodeEncodeError on Windows, try specifying this environment variable before executing Kalamine:
$Env:PYTHONUTF8 = 1
Layout Generation
Draw your keyboard layout in one of the provided ASCII-art templates and include it in a TOML document:
name = "qwerty-ansi"
name8 = "q-ansi"
description = "QWERTY-US layout"
version = "1.0.0"
geometry = "ANSI"
base = '''
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┲━━━━━━━━━━┓
│ ~ │ ! │ @ │ # │ $ │ % │ ^ │ & │ * │ ( │ ) │ _ │ + ┃ ┃
│ ` │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ = ┃ ⌫ ┃
┢━━━━━┷━━┱──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┺━━┯━━━━━━━┩
┃ ┃ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ { │ } │ | │
┃ ↹ ┃ │ │ │ │ │ │ │ │ │ │ [ │ ] │ \ │
┣━━━━━━━━┻┱────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┲━━━━┷━━━━━━━┪
┃ ┃ A │ S │ D │ F │ G │ H │ J │ K │ L │ : │ " ┃ ┃
┃ ⇬ ┃ │ │ │ │ │ │ │ │ │ ; │ ' ┃ ⏎ ┃
┣━━━━━━━━━┻━━┱──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┲━━┻━━━━━━━━━━━━┫
┃ ┃ Z │ X │ C │ V │ B │ N │ M │ < │ > │ ? ┃ ┃
┃ ⇧ ┃ │ │ │ │ │ │ │ , │ . │ / ┃ ⇧ ┃
┣━━━━━━━┳━━━━┻━━┳━━┷━━━━┱┴─────┴─────┴─────┴─────┴─────┴─┲━━━┷━━━┳━┷━━━━━╋━━━━━━━┳━━━━━━━┫
┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃
┃ Ctrl ┃ super ┃ Alt ┃ ␣ ┃ Alt ┃ super ┃ menu ┃ Ctrl ┃
┗━━━━━━━┻━━━━━━━┻━━━━━━━┹────────────────────────────────┺━━━━━━━┻━━━━━━━┻━━━━━━━┻━━━━━━━┛
'''
Build it:
kalamine ansi.toml
Get all keyboard drivers:
dist/
├─ q-ansi.klc # Windows
├─ q-ansi.keylayout # macOS
├─ q-ansi.xkb # Linux (user)
├─ q-ansi.xkb_custom # Linux (root)
└─ q-ansi.json # web
You can also ask for a single target by specifying the file extension:
kalamine ansi.toml --out q-ansi.xkb_custom
Layout Installation
Windows
macOS
copy your *.keylayout file into:
either ~/Library/Keyboard Layouts for the current user only,
or /Library/Keyboard Layouts for all users;
restart your session;
the keyboard layout appears in the “Language and Text” preferences, “Input Methods” tab.
Linux (root)
Recent versions of XKB allow one custom keyboard layout in root space:
sudo cp layout.xkb_custom /usr/share/X11/xkb/symbols/custom
Your keyboard layout will be listed as “Custom” in the keyboard settings.
On Xorg you can also select your keyboard layout from the command line:
setxkbmap custom # select your keyboard layout
setxkbmap us # get back to QWERTY
Linux (user)
On Linux, if the xkb/symbols/custom hack can’t be used, *.xkb keyboard descriptions can be applied in user-space with xkbcomp:
xkbcomp -w10 layout.xkb $DISPLAY
This has limitations:
the keyboard layout won’t show up in the keyboard settings
media keys might stop working
unlikely to work on Wayland
Again, setxkbmap can be used to get back to the standard us-qwerty layout:
setxkbmap us
XKalamine
xkalamine is a Linux-specific CLI tool for managing keyboard layouts with XKB.
# Apply a keyboard layout in user-space
# (equivalent to `xkbcomp -w10 layout.xkb $DISPLAY`)
xkalamine apply layout.toml
# Install a keyboard layout into /usr/share/X11/xkb
sudo xkalamine install layout.toml
# Uninstall Kalamine layouts from /usr/share/X11/xkb
sudo xkalamine remove us/prog # remove the kalamine 'prog' layout
sudo xkalamine remove fr # remove all kalamine layouts for French
sudo xkalamine remove "*" # remove all kalamine layouts
# List available keyboard layouts
xkalamine list # list all kalamine layouts
xkalamine list fr # list all kalamine layouts for French
xkalamine list us --all # list all layouts for US English
xkalamine list --all # list all layouts, ordered by locale
Using xkalamine with sudo currently supposes kalamine has been installed as root (hopefully in a pyenv). Which really sucks, and we’re working on a better solution.
XKB is a tricky piece of software. The following resources might be helpful if you want to dig in:
Alternative
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file kalamine-0.16.tar.gz
.
File metadata
- Download URL: kalamine-0.16.tar.gz
- Upload date:
- Size: 31.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffe350c73626e75a013c6e55f06e2cac09c23d79eb37d5765313be5672dee34b |
|
MD5 | 99759d200ffbc20469a1a6233b7cf871 |
|
BLAKE2b-256 | 3462f0e80db974a6a604bcb3cd8cfe2152d02d2708119f228271f2b66fb7fbc6 |
File details
Details for the file kalamine-0.16-py3-none-any.whl
.
File metadata
- Download URL: kalamine-0.16-py3-none-any.whl
- Upload date:
- Size: 36.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb9579e78fac85fd76f8200e5caa9050f38bf83f90952953cf4a9cd664b8729c |
|
MD5 | e347a35b51cebec1cd36f3cb66146925 |
|
BLAKE2b-256 | 1c8a74e5871ec26af09fe5c9f46bac3f3f1dd49bc03d0eee8da55d653fe14174 |