Converts Keyboard Layout Files to TUXEDO Computers SVG keyboard layout.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
neil 5e4b4a1151 Mise à jour de 'README.md' 1 month ago
.git-assets adding fr-azerty output and png 1 month ago
klf implementing NOALTKEYS and ALTKEYS_FOR_NUM params 1 month ago
output implementing NOALTKEYS and ALTKEYS_FOR_NUM params 1 month ago
svg initial commit 1 month ago
LICENSE Initial commit 1 month ago
README.md Mise à jour de 'README.md' 1 month ago
keys.txt initial commit 1 month ago
klf2tux.py implementing NOALTKEYS and ALTKEYS_FOR_NUM params 1 month ago
translations.json initial commit 1 month ago

README.md

klf2tux

Converts Keyboard Layout Files to TUXEDO Computers SVG keyboard layout.

Works with Python 3.

Allows anyone to convert their personal keyboard layout from XKB, PKL, KLC, Keylayout, TMK and AHK format to a TUXEDO keyboard layout SVG file for laser printing.

NB: "Keyboard Layout Files" refers to the JSON format generated by the klfc tool. It isn't an official term.

klfc is a tool to convert keyboard layout formats. klf2tux uses their JSON output format to replace values in Tuxedo's SVG keyboard layout, which first needs to be edited to be a "template SVG".

How-to

Create a SVG template

The first step is to get a SVG keyboard layout template. If you already have one, you can skip this step.

If you can't find the corresponding template for your model, you'll have make it from one of the official SVG keyboard layouts from TUXEDO Computers repositories, which are open-source and available here: https://github.com/tuxedocomputers/keyboard-layouts

Here's an example with the InfinityBook Pro 15.

The official keyboard layout for this model (with QWERTY en-US) looks like this:

InfinityBook Pro 15 official layout

  • Open your favourite SVG editor (Inkscape is fine) and replace all the letters with the percent % sign.
    • Write four % per key (for regular, Shift, AltGr and Shift+AltGr letters).
    • Try to align them all, to center them perfectly on each single key. Use the measurement tool and the zoom for more accuracy.

InfinityBook Pro 15 template (transition)

You've done half of the work.

  • Replace translated texts like "Home" or "SysRq" with the corresponding template value.
    • Check out keys.txt file and/or the template below to know which value you should write.
    • You don't care if it the text is larger than the key, the script will replace it anyway.
    • Special case for ESC workaround: you must create two "Esc" keys (%ESC1 and %ESC2) to avoid overflow if the "Esc" translation is larger than 3 characters.
  • Replace each percent with its corresponding uppercase letter on the QWERTY keyboard layout and the following letter:
    • N for a regular lowercase (bottom-left) letter ;
    • U for an uppercase (top-left) letter ;
    • A for a lowercase AltGr letter ;
    • G for an uppercase AltGr letter.
    • For example, the uppercase Q letter will become %QU on the keyboard.
      • Accordingly, Q key on the keyboard will have %QN at the bottom-left, %QU at the top-left, %QA at the bottom-right and %QG at the top-right.
  • Note: Since this step is a hassle, you can try to copy-paste all keys from an already existing template, for another computer model, which uses the same (or similar) spacing as yours.

Here's the final result for the model we're working with:

InfinityBook Pro 15 final template

You're done. Please consider making your work available to other people by uploading it and sharing it, so no one will have to go through this hassle again.

Convert your keyboard layout to KLF

Now the easy steps.

We'll use klfc to convert your layout to a JSON format.

At the time of writing, klfc supports XKB, PKL, KLC, keylayout, TMK and AHK formats.

git clone https://github.com/39aldo39/klfc
cd klfc
./klfc <your keyboard layout> > your-layout.klf

You can find the default keyboard layouts in /usr/share/X11/xkb/symbols/ for most Linux distributions.

For example, to get the French AZERTY keyboard layout from a XKB file, use this command:

./klfc "/usr/share/X11/xkb/symbols/fr(azerty)" > fr-azerty.klf

This is the most simple AZERTY variant, but you can use another variant by changing the variant name in parenthesis.

Don't forget that if you decide do use a variant with a lot of AltGr and AltGr+Shift keys, your keyboard layout will display those keys as well, so you might prefer simplified layouts.

Beware of the layout type of your computer model (ISO vs ANSI). Your selected layout might not include a binding for the "Iso" key. More information about this here.

Please refer to klfc's documentation for help: https://github.com/39aldo39/klfc

Convert your KLF to a TUXEDO Computers keyboard layout using your model template

Now you should have everything you need.

git clone https://git.42l.fr/neil/klf2tux
cd klf2tux
./klf2tux.py <yourtemplate.svg> <yourlayout.klf> <your language code> > final-layout.svg

Replace:

  • yourtemplate.svg with your SVG keyboard template
  • yourlayout.klf with the JSON file you just retreived from klfc
  • your language code with a two-letter code representing your language. For now, klf2tux supports en, fr and de. Feel free to add your own language or to edit translated strings in translations.json.

Example (used to generate example outputs in the output/ folder):

./klf2tux.py "svg/InfinityBook Pro 15 - Inter.svg" klf/azerty-simple.klf fr > output/fr-azerty-simple.svg
./klf2tux.py "svg/InfinityBook Pro 15 - Inter.svg" klf/bepo.klf fr > output/fr-bepo.svg
./klf2tux.py "svg/InfinityBook Pro 15 - Inter.svg" klf/qwerty-simple.klf en > output/en-qwerty-simple.svg
./klf2tux.py "svg/InfinityBook Pro 15 - Inter.svg" klf/qwerty-intl.klf en > output/en-qwerty-intl.svg
./klf2tux.py "svg/InfinityBook Pro 15 - Inter.svg" klf/qwertz.klf de > output/de-qwertz.svg

Double check the final result. Check if everything is mapped correctly: the Iso key, Escape key... also ensure that no letters or words are larger than the keys. If it isn't the case, you can slightly edit the SVG file manually. Feel free to upload your work for other people.

Then you have your final result:

Final result for InfinityBook Pro 15, French AZERTY keyboard, simple variant

Tips

Print a clean layout with script parameters

Unless you prefer having all the letters (including AltGr and AltGr+Shift) displayed on your keyboard, the easiest way to map your layout is to find a simplified layout in /usr/share/X11/xkb/symbols/.

If you can't find a simplified layout, you can edit the script (lines 15 and 21) and set the following values:

  • NOALTKEYS to True
  • ALTKEYS_FOR_NUM to True

This will hide all AltGr and AltGr+Shift keys from the layout, except AltGr keys for the number row (which seems to be an average standard). If you don't want the AltGr keys in the number row, set ALTKEYS_FOR_NUM to False.

Hide duplicate letters

HIDE_DUPLICATE is enabled by default and will prevent the same letters from appearing on the same key (e.g. if / and altgr+/ both prints a /, the altgr+/ key will be hidden).

If you don't want this behavior, set the HIDE_DUPLICATE variable to False.

Licensing

Disclaimer: I'm not personally affiliated with TUXEDO Computers of any way.

klf2tux.py is under WTFPL.

This repository includes partial content from: