### Install Nix Package Manager Source: https://github.com/urob/zmk-config/blob/main/readme.md Installs the Nix package manager with flake support enabled. This command downloads and executes the Nix installer script. ```bash # Install Nix with flake support enabled curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | \ sh -s -- install --no-confirm # Start the nix daemon without restarting the shell . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh ``` -------------------------------- ### Install direnv and nix-direnv using Nix Source: https://github.com/urob/zmk-config/blob/main/readme.md Installs the direnv and nix-direnv tools using the Nix package manager. These tools help manage environment variables and integrate Nix with direnv. ```bash nix profile install nixpkgs#direnv nixpkgs#nix-direnv ``` -------------------------------- ### Initialize ZMK Workspace with Just Source: https://context7.com/urob/zmk-config/llms.txt Sets up the ZMK workspace by initializing west, pulling dependencies, and exporting Zephyr. This involves cloning the repository, allowing direnv for Nix environment setup, and running `just init` which executes west commands. ```bash # Clone the repository git clone https://github.com/urob/zmk-config zmk-workspace cd zmk-workspace # Allow direnv to set up the Nix environment (first time takes a while) direnv allow # Initialize the Zephyr workspace and pull ZMK dependencies just init # This runs the equivalent of: # west init -l config # west update --fetch-opt=--filter=blob:none # west zephyr-export ``` -------------------------------- ### Initialize ZMK Workspace and Build Environment Source: https://github.com/urob/zmk-config/blob/main/readme.md Navigates into the ZMK workspace directory and initializes the development environment using 'direnv allow' and 'just init'. This sets up dependencies and the Zephyr workspace. ```bash # The first time you enter the workspace, you will be prompted to allow direnv cd zmk-workspace # Allow direnv for the workspace, which will set up the environment (this takes a while) direnv allow # Initialize the Zephyr workspace and pull in the ZMK dependencies # (same as `west init -l config && west update && west zephyr-export`) just init ``` -------------------------------- ### Build ZMK Firmware using 'just' Source: https://github.com/urob/zmk-config/blob/main/readme.md Builds the ZMK firmware for all configured board and shield combinations using the 'just build all' command. It also shows how to build for specific targets or pass arguments to 'west'. ```bash # Build the firmware for all board and shield combinations just build all # Build firmware for a specific target (e.g., 'zen') just build zen # Trigger a pristine build by passing arguments to west just build all -p # List all available build targets just list # Clean the build cache just clean ``` -------------------------------- ### Draw ZMK Keymap using 'just' Source: https://github.com/urob/zmk-config/blob/main/readme.md Parses the base keymap file ('base.keymap') and generates an SVG representation of the keymap using the 'keymap-drawer' tool via the 'just draw' command. ```bash just draw ``` -------------------------------- ### Build ZMK Firmware with Just Source: https://context7.com/urob/zmk-config/llms.txt Compiles ZMK firmware for specified targets by parsing `build.yaml`. Output files are placed in the `firmware/` directory. Supports building all targets, specific targets by name, pristine builds, listing targets, and cleaning build artifacts. ```bash # Build firmware for all targets defined in build.yaml just build all # Build firmware for a specific target (matches partial names) just build zen # Builds corneish_zen_v2_left and corneish_zen_v2_right just build glove80 # Builds glove80_lh and glove80_rh just build planck # Builds planck_rev6 # Pristine build (clean build cache first) just build all -p # List all available build targets just list # Output: # corneish_zen_v2_left corneish_zen_v2_right glove80_lh # glove80_rh planck_rev6 # Clean build cache and firmware artifacts just clean ``` -------------------------------- ### Define CI and Local Build Combinations (build.yaml) Source: https://context7.com/urob/zmk-config/llms.txt The build.yaml file configures the matrix for GitHub Actions and local builds, specifying the board and shield combinations to be used. It is a simple YAML file listing the desired configurations. ```yaml # build.yaml - GitHub Actions matrix configuration --- include: - board: planck_rev6 - board: corneish_zen_v2_left - board: corneish_zen_v2_right - board: glove80_lh - board: glove80_rh ``` -------------------------------- ### Clone ZMK Configuration Repository Source: https://github.com/urob/zmk-config/blob/main/readme.md Clones the user's fork of the ZMK configuration repository. This repository serves as the root for the development environment. ```bash # Replace `urob` with your username git clone https://github.com/urob/zmk-config zmk-workspace ``` -------------------------------- ### Draw Keymap Visualization with Just Source: https://context7.com/urob/zmk-config/llms.txt Generates an SVG visualization of the keymap using the `keymap-drawer` tool. This command creates `draw/base.yaml` with parsed keymap data and `draw/base.svg` representing all layers of the keymap. ```bash # Generate keymap visualization just draw # Output files: # draw/base.yaml - Parsed keymap data # draw/base.svg - SVG visualization of all layers ``` -------------------------------- ### Configure direnv Shell Hook for Bash Source: https://github.com/urob/zmk-config/blob/main/readme.md Sets up the direnv shell hook for the bash shell and enables nix-direnv integration. It also includes optional configuration to reduce direnv's verbosity. ```bash # Install the shell-hook echo 'eval "$(direnv hook bash)"' >> ~/.bashrc # Enable nix-direnv (if installed in the previous step) mkdir -p ~/.config/direnv echo 'source $HOME/.nix-profile/share/nix-direnv/direnvrc' >> ~/.config/direnv/direnvrc # Optional: make direnv less verbose echo '[global]\nwarn_timeout = "2m"\nhide_env_diff = true' >> ~/.config/direnv/direnv.toml # Source the bashrc to activate the hook (or start a new shell) source ~/.bashrc ``` -------------------------------- ### Configure Smart-Mouse Auto-Layer with Tri-State Behavior (C) Source: https://context7.com/urob/zmk-config/llms.txt Sets up a 'Smart-Mouse' auto-layer using the `ZMK_TRI_STATE` behavior, which requires the `zmk-tri-state` module. This layer provides mouse movement and scroll controls and automatically deactivates when other keys are pressed. It also defines a combo to activate this layer. ```c #define MOUSE 5 // Mouse layer index // Smart-mouse using tri-state behavior (requires zmk-tri-state module) ZMK_TRI_STATE( smart_mouse, bindings = <&tog MOUSE>, <&none>, <&tog MOUSE>; ignored-key-positions = ; ignored-layers = ;) // Activate via combo (W + P keys) ZMK_COMBO(mouse, &smart_mouse, LT2 LT1, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST) // Mouse layer bindings #define U_MS_U &mmv MOVE_UP #define U_MS_D &mmv MOVE_DOWN #define U_MS_L &mmv MOVE_LEFT #define U_MS_R &mmv MOVE_RIGHT #define U_WH_U &msc SCRL_UP #define U_WH_D &msc SCRL_DOWN ``` -------------------------------- ### Pin ZMK Modules and Dependencies (west.yml) Source: https://context7.com/urob/zmk-config/llms.txt The west.yml manifest file pins all project dependencies, including ZMK modules, the Zephyr RTOS, and the ZMK firmware itself. It specifies remotes, projects, and their respective revisions or branches to ensure reproducible builds. ```yaml # config/west.yml --- manifest: defaults: remote: urob revision: v0.3 # Pin everything to v0.3 remotes: - name: urob url-base: https://github.com/urob - name: zmkfirmware url-base: https://github.com/zmkfirmware projects: - name: zmk remote: zmkfirmware import: app/west.yml # ZMK modules - name: zmk-adaptive-key path: modules/zmk/adaptive-key - name: zmk-auto-layer path: modules/zmk/auto-layer - name: zmk-helpers path: modules/zmk/helpers - name: zmk-leader-key path: modules/zmk/leader-key - name: zmk-tri-state path: modules/zmk/tri-state - name: zmk-unicode path: modules/zmk/unicode # Zephyr with minimal modules - name: zephyr remote: zmkfirmware revision: v3.5.0+zmk-fixes clone-depth: 1 import: name-allowlist: - cmsis - hal_nordic - hal_rpi_pico - hal_stm32 - lvgl - tinycrypt self: path: config ``` -------------------------------- ### Implement Numword Auto-Layer with Hold-Tap and Tap-Dance (C) Source: https://context7.com/urob/zmk-config/llms.txt Configures an auto-toggling number layer named 'Numword' using ZMK behaviors. It leverages `ZMK_HOLD_TAP` for tap, double-tap, and hold functionalities, and `ZMK_TAP_DANCE` for managing different actions based on tap frequency. This requires the `num_word.dtsi` behavior file. ```c #include #define NUM 3 // Number layer index // Tap: num-word | Double-tap: sticky num-layer | Hold: num-layer #define SMART_NUM &smart_num NUM 0 ZMK_HOLD_TAP(smart_num, bindings = <&mo>, <&num_dance>; flavor = "balanced"; tapping-term-ms = <200>; quick-tap-ms = <175>;) ZMK_TAP_DANCE(num_dance, bindings = <&num_word NUM>, <&sl NUM>; tapping-term-ms = <200>;) // Usage: Place SMART_NUM on a thumb key // - Tap: Activates Numword (auto-deactivates after typing non-numbers) // - Double-tap: Activates sticky number layer (one-shot) // - Hold: Activates number layer while held ``` -------------------------------- ### Define ZMK Leader Key Sequences Source: https://context7.com/urob/zmk-config/llms.txt Defines the ZMK_LEADER_SEQUENCE macro to create custom leader key sequences. This macro requires the 'zmk-leader-key' module and allows for triggering complex behaviors with key sequences, including German umlauts, Greek letters, and system commands. It takes a name, leader bindings, and the sequence itself as arguments. ```c #define ZMK_LEADER_SEQUENCE(name, leader_bindings, leader_sequence) \ / { \ behaviors { \ leader: leader { \ compatible = "zmk,behavior-leader-key"; \ #binding-cells = <0>; \ ignore-keys = ; \ leader_sequence_ ## name { \ bindings = ; \ sequence = ; \ }; \ }; \ }; \ }; // German umlauts (Leader + single key) ZMK_LEADER_SEQUENCE(de_ae, &uc UC_DE_AE, A) // ä ZMK_LEADER_SEQUENCE(de_oe, &uc UC_DE_OE, O) // ö ZMK_LEADER_SEQUENCE(de_ue, &uc UC_DE_UE, U) // ü ZMK_LEADER_SEQUENCE(de_eszett, &uc UC_DE_SS, S) // ß // Greek letters (Leader + E + letter) ZMK_LEADER_SEQUENCE(el_alpha, &uc UC_EL_ALPHA, E A) // α ZMK_LEADER_SEQUENCE(el_beta, &uc UC_EL_BETA, E B) // β ZMK_LEADER_SEQUENCE(el_pi, &uc UC_EL_PI, E P) // π ZMK_LEADER_SEQUENCE(el_sigma, &uc UC_EL_SIGMA, E S) // σ // System commands (Leader + word) ZMK_LEADER_SEQUENCE(reset, &sys_reset, R E S E T) ZMK_LEADER_SEQUENCE(boot, &bootloader, B O O T) #ifdef CONFIG_WIRELESS ZMK_LEADER_SEQUENCE(usb, &out OUT_USB, U S B) ZMK_LEADER_SEQUENCE(ble, &out OUT_BLE, B L E) #endif ``` -------------------------------- ### ZMK Hold-Tap Configuration for Left-Hand HRMs Source: https://github.com/urob/zmk-config/blob/main/readme.md Configures hold-tap behavior for the left-hand home row modifiers using ZMK. It employs a 'balanced' flavor, sets tapping and quick-tap durations, and requires prior idle time to resolve taps quickly. It also defines key positions for triggering holds and enables triggering on release. ```c++ #include "zmk-helpers/key-labels/36.h" // Source key-labels. #define KEYS_L LT0 LT1 LT2 LT3 LT4 LM0 LM1 LM2 LM3 LM4 LB0 LB1 LB2 LB3 LB4 // Left-hand keys. #define KEYS_R RT0 RT1 RT2 RT3 RT4 RM0 RM1 RM2 RM3 RM4 RB0 RB1 RB1 RB2 RB3 RB4 // Right-hand keys. #define THUMBS LH2 LH1 LH0 RH0 RH1 RH2 // Thumb keys. /* Left-hand HRMs. */ ZMK_HOLD_TAP(hml, flavor = "balanced"; tapping-term-ms = <280>; quick-tap-ms = <175>; require-prior-idle-ms = <150>; bindings = <&kp>, <&kp>; hold-trigger-key-positions = ; hold-trigger-on-release; ) ``` -------------------------------- ### Configure Corneish Zen Board-Specific Layout Source: https://context7.com/urob/zmk-config/llms.txt Defines board-specific keymap configurations for the Corneish Zen keyboard. It sets up the `ZMK_BASE_LAYER` macro to incorporate board-specific keys into the 34-key core layout and includes necessary headers for physical layout definition. ```c // config/corneish_zen.keymap #define CONFIG_WIRELESS #define ZMK_BASE_LAYER(name, LT, RT, LM, RM, LB, RB, LH, RH) \ ZMK_LAYER( \ name, \ LT RT \ LM RM \ LB RB \ &kp LGUI LH RH &smart_mouse \ ) #include "zmk-helpers/key-labels/36.h" #include "base.keymap" /{ chosen { zmk,physical-layout = &foostan_corne_5col_layout; }; }; ``` -------------------------------- ### Define ZMK Combos with Timeouts and Idle Requirements (C) Source: https://context7.com/urob/zmk-config/llms.txt Defines custom key combinations using the ZMK_COMBO macro. It allows configuration of timeout and idle requirements to prevent misfires during rapid typing. This macro is essential for creating multi-key sequences or layers activated by specific key presses. ```c #define COMBO_TERM_FAST 18 #define COMBO_TERM_SLOW 30 #define COMBO_IDLE_FAST 150 #define COMBO_IDLE_SLOW 50 // Horizontal combos - left hand ZMK_COMBO(esc, &kp ESC, LT3 LT2, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST) ZMK_COMBO(mouse, &smart_mouse, LT2 LT1, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST) ZMK_COMBO(tab, &kp TAB, LM3 LM2, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST) ZMK_COMBO(cut, &kp LC(X), LB3 LB1, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST) ZMK_COMBO(copy, &kp LC(INS), LB3 LB2, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST) ZMK_COMBO(paste, &kp LS(INS), LB2 LB1, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST) // Horizontal combos - right hand ZMK_COMBO(bspc, &kp BSPC, RT1 RT2, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST) ZMK_COMBO(del, &kp DEL, RT2 RT3, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST) ZMK_COMBO(lpar, &kp LPAR, RM1 RM2, DEF NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST) ZMK_COMBO(rpar, &kp RPAR, RM2 RM3, DEF NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST) ZMK_COMBO(lbkt, &kp LBKT, RB1 RB2, DEF NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST) ZMK_COMBO(rbkt, &kp RBKT, RB2 RB3, DEF NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST) // Vertical combos - symbols (slower timing for diagonal presses) ZMK_COMBO(at, &kp AT, LT3 LM3, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW) ZMK_COMBO(hash, &kp HASH, LT2 LM2, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW) ZMK_COMBO(plus, &kp PLUS, RT1 RM1, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW) ZMK_COMBO(minus, &kp MINUS, RM1 RB1, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW) ``` -------------------------------- ### ZMK Hold-Tap Configuration for Right-Hand HRMs Source: https://github.com/urob/zmk-config/blob/main/readme.md Configures hold-tap behavior for the right-hand home row modifiers using ZMK. Similar to the left-hand configuration, it uses a 'balanced' flavor, defines timing parameters, and specifies key positions for hold triggers, including triggering on release. ```c++ /* Right-hand HRMs. */ ZMK_HOLD_TAP(hmr, flavor = "balanced"; tapping-term-ms = <280>; quick-tap-ms = <175>; require-prior-idle-ms = <150>; bindings = <&kp>, <&kp>; hold-trigger-key-positions = ; hold-trigger-on-release; ) ``` -------------------------------- ### Configure Magic Shift Key Behavior Source: https://context7.com/urob/zmk-config/llms.txt Defines the MAGIC_SHIFT macro and associated behaviors for a magic shift key. This key provides adaptive functionality: key repeat after alphas, sticky shift after other keys, caps-word on double-tap, and regular shift on hold. It utilizes ZMK_HOLD_TAP and ZMK_MOD_MORPH to achieve these multi-layered behaviors. ```c #define QUICK_TAP_MS 175 // Magic shift: Tap after alpha = repeat, else sticky-shift // Shift + tap or double-tap: caps-word | Hold: shift #define MAGIC_SHIFT &magic_shift LSHFT 0 ZMK_HOLD_TAP(magic_shift, bindings = <&kp>, <&magic_shift_tap>; flavor = "balanced"; tapping-term-ms = <200>; quick-tap-ms = ;) ZMK_MOD_MORPH(magic_shift_tap, bindings = <&shift_repeat>, <&caps_word>; mods = <(MOD_LSFT)>;) // Adaptive key: repeat after alphas, sticky shift otherwise ZMK_ADAPTIVE_KEY( shift_repeat, bindings = <&sk LSHFT>; repeat { trigger-keys = ; bindings = <&key_repeat>; max-prior-idle-ms = <1200>; strict-modifiers; }) // Usage: Place MAGIC_SHIFT on a thumb key // - Type "hello" then tap magic-shift: outputs "o" (repeat) // - Type "." then tap magic-shift: activates sticky shift for next key // - Double-tap or Shift+tap: activates caps-word mode // - Hold: regular shift modifier ``` -------------------------------- ### ZMK Homerow Mods Configuration (C) Source: https://context7.com/urob/zmk-config/llms.txt Configures 'timeless' homerow mods (HRMs) in ZMK using `ZMK_HOLD_TAP` macro. It utilizes `balanced` flavor, large tapping-term, positional hold-tap, and `require-prior-idle-ms` to minimize misfires while maintaining typing fluency. Includes definitions for left-hand, right-hand, and thumb keys. ```c #include "zmk-helpers/key-labels/36.h" #include // Define key position groups #define KEYS_L LT0 LT1 LT2 LT3 LT4 LM0 LM1 LM2 LM3 LM4 LB0 LB1 LB2 LB3 LB4 // Left-hand keys #define KEYS_R RT0 RT1 RT2 RT3 RT4 RM0 RM1 RM2 RM3 RM4 RB0 RB1 RB2 RB3 RB4 // Right-hand keys #define THUMBS LH2 LH1 LH0 RH0 RH1 RH2 // Thumb keys // Macro to create HRM behaviors #define MAKE_HRM(NAME, HOLD, TAP, TRIGGER_POS) \ ZMK_HOLD_TAP(NAME, bindings = , ; flavor = "balanced"; \ tapping-term-ms = <280>; quick-tap-ms = <175>; \ require-prior-idle-ms = <150>; hold-trigger-on-release; \ hold-trigger-key-positions = ;) // Create left-hand and right-hand HRMs MAKE_HRM(hml, &kp, &kp, KEYS_R THUMBS) // Left-hand HRMs trigger on right keys MAKE_HRM(hmr, &kp, &kp, KEYS_L THUMBS) // Right-hand HRMs trigger on left keys // Usage in keymap layer: // &hml LGUI A - Tap: 'A', Hold: GUI modifier // &hml LALT R - Tap: 'R', Hold: ALT modifier // &hmr RSHFT E - Tap: 'E', Hold: SHIFT modifier ``` -------------------------------- ### Define SIMPLE_MORPH for Shifted Key Variants Source: https://context7.com/urob/zmk-config/llms.txt Defines the SIMPLE_MORPH macro to create mod-morph behaviors with a single modifier trigger. This simplifies defining keys that output different characters based on active modifiers, such as comma becoming semicolon when Shift is held. It takes a name, the modifier, and two bindings as arguments. ```c #define SIMPLE_MORPH(NAME, MOD, BINDING1, BINDING2) \ ZMK_MOD_MORPH(NAME, mods = <(MOD_L##MOD | MOD_R##MOD)>; \ bindings = , ;) // Tap: comma | Shift + tap: semicolon | Ctrl + Shift + tap: < SIMPLE_MORPH(comma_morph, SFT, &kp COMMA, &comma_inner_morph) SIMPLE_MORPH(comma_inner_morph, CTL, &kp SEMICOLON, &kp LESS_THAN) // Tap: dot | Shift + tap: colon | Ctrl + Shift + tap: > SIMPLE_MORPH(dot_morph, SFT, &kp DOT, &dot_inner_morph) SIMPLE_MORPH(dot_inner_morph, CTL, &kp COLON, &kp GREATER_THAN) // Tap: ? | Shift + tap: ! SIMPLE_MORPH(qexcl, SFT, &kp QMARK, &kp EXCL) // Tap: ( | Shift + tap: < SIMPLE_MORPH(lpar_lt, SFT, &kp LPAR, &kp LT) // Tap: ) | Shift + tap: > SIMPLE_MORPH(rpar_gt, SFT, &kp RPAR, &kp GT) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.