Sorry to start sounding like a broken record but I'd like to reiterate that set-keymap and set-x11-keymap are not orthogonal but they overstep each other: they BOTH change all XKB* variables *and* KEYMAP. Unless the toggle "--no-convert" is used that is. Namely, if a user has configured KEYMAP != XKBLAYOUT, no sequence of set-keymap / set-x11-keymap will ever be able to reproduce that configuration and the user settings will be inevitably overidden. That is not my case but I'm just pointing out a limitation of the current approach. Taking a step back, I don't know about the big picture but I'm wondering about the role of the script "keytable". If it is to just provide sensible defaults in case some settings are missing, maybe this logic might do the trick: if KEYMAP and XKBLAYOUT are defined do nothing (and preserve user settings) else if KEYMAP is defined but not XKBLAYOUT set-keymap KEYMAP (which will also implicitly set XKB*) else do nothing (current behavior) fi