Let shortcuts be rebound from Settings
Every bind in keybinds.lua now goes through a small wrapper that substitutes the chord from a stored override. Only the chord is taken from settings; the action is always the Lua value written in that file, so an override can move a shortcut but can never make one do something else. That is the property that makes reading them from a file the user can edit safe, and it is why the alternative -- storing dispatchers -- was not considered. Overrides are keyed by the shipped chord rather than the description. Keying by description moved every bind that shared one: rebinding SUPER+C also moved the XF86Calculator hardware key onto the same chord, silently costing it. Chords are unique; descriptions are not. Applying needs hyprctl reload rather than a live hl.bind. Hyprland reports Lua-defined binds with dispatcher "__lua" and a bytecode offset, so the action cannot be reconstructed from outside to re-bind it; reload re-runs the config, which re-reads the settings file. The capture control ignores modifier-only presses, because every chord passes through them and holding Super would otherwise be captured the moment the modifier went down. It refuses a bare letter, which would swallow ordinary typing, and refuses a key with no keysym name rather than storing something that would fail to bind. Rebinding onto a chord already in use is refused rather than shadowing the existing shortcut. The refactor was verified by snapshotting all 113 binds before and after: the keymap is byte-identical, and identical again after applying an override and resetting it. Claude-Session: https://claude.ai/code/session_01BRvzt4H8XXLPVH5MyYdk9L
This commit is contained in:
@@ -492,6 +492,22 @@ Singleton {
|
||||
]
|
||||
},
|
||||
|
||||
// ── Keyboard shortcut overrides ─────────────────────────────────────
|
||||
// { "<bind description>": "<chord>" }. Only the chord is stored: the
|
||||
// action always comes from hypr/keybinds.lua, so an override can move a
|
||||
// shortcut but can never make one do something else. The Lua validates
|
||||
// each chord and falls back to the shipped one, so a hand-edited file
|
||||
// cannot cost you a keymap.
|
||||
//
|
||||
// Edited through the Input & Shortcuts page rather than as a row, hence
|
||||
// internal.
|
||||
{
|
||||
key: "keybindOverrides", type: "json", def: ({}), group: "input",
|
||||
internal: true,
|
||||
label: "Keyboard shortcut overrides",
|
||||
detail: "Shortcuts you have moved from their shipped chord"
|
||||
},
|
||||
|
||||
// ── Internal ────────────────────────────────────────────────────────
|
||||
{
|
||||
key: "lastPage", type: "string", def: "home", group: "internal",
|
||||
|
||||
Reference in New Issue
Block a user