Bootmapper - change RGB on layer switch

uint32_t layer_state_set_user(uint32_t state) {
    rgblight_config_t eeprom;
    switch (biton32(state)) {
        case _FN:
            rgblight_setrgb(0xFF, 0x33, 0x00);
            rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
            break;
        default:
            eeprom.raw = eeconfig_read_rgblight();
            rgblight_mode_noeeprom(eeprom.mode);
            break;
    }
    return state;
}

This is how I usually do it:
Add the above function to your keymap.c and adapt to your needs.

  • case _FN → _FN is the name of the layer. If you use numbers instead of names for layers just use those
  • replace the rgb_ Funtctions with the ones you want to use. I’d advise to use the noeeprom functions where possible.
  • the default state restores the RGB configuration from your base layer. This only works thought if you have used the noeeprom functions as stated above.

Results in this:

Hope this helps you out and please don’t hesitate to ask any questions, will try my best to help out :slight_smile:

2 Likes