keyboard stuff
at master 106 lines 5.5 kB view raw view rendered
1# External QMK Userspace 2 3QMK Firmware now officially supports storing user keymaps outside of the normal QMK Firmware repository, allowing users to maintain their own keymaps without having to fork, modify, and maintain a copy of QMK Firmware themselves. 4 5External Userspace mirrors the structure of the main QMK Firmware repository, but only contains the keymaps that you wish to build. You can still use `keyboards/<my keyboard>/keymaps/<my keymap>` to store your keymaps, or you can use the `layouts/<my layout>/<my keymap>` system as before -- they're just stored external to QMK Firmware. 6 7The build system will still honor the use of `users/<my keymap>` if you rely on the traditional QMK Firmware [userspace feature](feature_userspace) -- it's now supported externally too, using the same location inside the External Userspace directory. 8 9Additionally, there is first-class support for using GitHub Actions to build your keymaps, allowing you to automatically compile your keymaps whenever you push changes to your External Userspace repository. 10 11::: warning 12External Userspace is new functionality and may have issues. Tighter integration with the `qmk` command will occur over time. 13::: 14 15::: tip 16Historical keymap.json and GitHub-based firmware build instructions can be found [here](newbs_building_firmware_workflow). This document supersedes those instructions, but they should still function correctly. 17::: 18 19## Setting up QMK Locally 20 21If you wish to build on your local machine, you will need to set up QMK locally. This is a one-time process, and is documented in the [newbs setup guide](newbs). 22 23::: warning 24If you wish to use any QMK CLI commands related to manipulating External Userspace definitions, you will currently need a copy of QMK Firmware as well. 25::: 26 27::: warning 28Building locally has a much shorter turnaround time than waiting for GitHub Actions to complete. 29::: 30 31## External Userspace Repository Setup (forked on GitHub) 32 33A basic skeleton External Userspace repository can be found [here](https://github.com/qmk/qmk_userspace). If you wish to keep your keymaps on GitHub (strongly recommended!), you can fork the repository and use it as a base: 34 35![Userspace Fork](/hcegguh.png) 36 37Going ahead with your fork will copy it to your account, at which point you can clone it to your local machine and begin adding your keymaps: 38 39![Userspace Clone](/CWYmsk8.png) 40 41```sh 42cd $HOME 43git clone https://github.com/{myusername}/qmk_userspace.git 44qmk config user.overlay_dir="$(realpath qmk_userspace)" 45``` 46 47## External Userspace Setup (locally stored only) 48 49If you don't want to use GitHub and prefer to keep everything local, you can clone a copy of the default External Userspace locally instead: 50 51```sh 52cd $HOME 53git clone https://github.com/qmk/qmk_userspace.git 54qmk config user.overlay_dir="$(realpath qmk_userspace)" 55``` 56 57## Adding a Keymap 58 59_These instructions assume you have already set up QMK locally, and have a copy of the QMK Firmware repository on your machine._ 60 61Keymaps within External Userspace are defined in the same way as they are in the main QMK repository. You can either use the `qmk new-keymap` command to create a new keymap, or manually create a new directory in the `keyboards` directory. 62 63Alternatively, you can use the `layouts` directory to store your keymaps, using the same layout system as the main QMK repository -- if you choose to do so you'll want to use the path `layouts/<layout name>/<keymap name>/keymap.*` to store your keymap files, where `layout name` matches an existing layout in QMK, such as `tkl_ansi`. 64 65After creating your new keymap, building the keymap matches normal QMK usage: 66 67```sh 68qmk compile -kb <keyboard> -km <keymap> 69``` 70 71::: warning 72The `qmk config user.overlay_dir=...` command must have been run when cloning the External Userspace repository for this to work correctly. 73::: 74 75## Adding the keymap to External Userspace build targets 76 77Once you have created your keymap, if you want to use GitHub Actions to build your firmware, you will need to add it to the External Userspace build targets. This is done using the `qmk userspace-add` command: 78 79```sh 80# for a keyboard/keymap combo: 81qmk userspace-add -kb <keyboard> -km <keymap> 82# or, for a json-based keymap (if kept "loose"): 83qmk userspace-add <relative/path/to/my/keymap.json> 84``` 85 86This updates the `qmk.json` file in the root of your External Userspace directory. If you're using a git repository to store your keymaps, now is a great time to commit and push to your own fork. 87 88## Compiling External Userspace build targets 89 90Once you have added your keymaps to the External Userspace build targets, you can compile all of them at once using the `qmk userspace-compile` command: 91 92```sh 93qmk userspace-compile 94``` 95 96All firmware builds you've added to the External Userspace build targets will be built, and the resulting firmware files will be placed in the root of your External Userspace directory. 97 98## Using GitHub Actions 99 100GitHub Actions can be used to automatically build your keymaps whenever you push changes to your External Userspace repository. If you have set up your list of build targets, this is as simple as enabling workflows in the GitHub repository settings: 101 102![Repo Settings](/EVkxOt1.png) 103 104Any push will result in compilation of all configured builds, and once completed a new release containing the newly-minted firmware files will be created on GitHub, which you can subsequently download and flash to your keyboard: 105 106![Releases](/zmwOL5P.png)