mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-23 00:44:15 +01:00
feat(hotkeys): plan the bindings and write the plain ones as KDE shortcut files
A binding can reach KDE in two ways. A `.desktop` file in a kglobalaccel directory is a static shortcut that KDE runs by itself: it shows in System Settings and survives a dead komorebi, but it is one combo that runs one command. Modes, chord chains, release bindings, per-application bindings, a blacklist and a pause binding need the engine, where komorebi registers the keys and decides what each press does. `plan::plan` sorts a keymap into the two: a binding is static when it is in the default mode, a single combo, unscoped and pressed, in a file with no modes, blacklist or pause binding. Notes say why each other binding goes through the engine. The static shortcut was meant to be the default unless it proved slow, and it did: on KWin 6.8.1 a static shortcut ran its command 233 ms after the key at the median, while the engine heard of it after 3 ms. `PlanMode::Engine` is therefore the default, and `Auto` and `Static` (no engine; what needs it is left out with a warning) stay selectable. `kde` is the skhdrc exporter of the first KDE prototype, moved: the same file names, the same `Exec` quoting for the desktop entry specification (`%%` included), the same `X-KDE-GlobalAccel-CommandShortcut` and `X-KDE-Shortcuts` keys, and `write` and `diff`, which replace the generated files and leave every other file alone. For the sample configuration the files are byte for byte the prototype's; its tests come along, and the corpus test checks that the sample plans into the same 50 files from each format.
This commit is contained in:
1 parent
e713d77272
commit
8f5d4a32ef
7 files changed
+969
-4
No files matched your search
@@ -722,3 +722,27 @@ recorded; this entry needs one.
|
||||
What is not plain syntax is expanded while the file is read: sxhkd's braces become one binding
|
||||
per alternative, and skhd's `.define` templates and application groups are replaced where
|
||||
they are used, so the model has only expanded bindings in it.
|
||||
|
||||
## Why are some bindings shortcut files, and the others the engine's?
|
||||
|
||||
A KDE global shortcut can be a `.desktop` file that KDE reads by itself. Such a static
|
||||
shortcut is robust: it shows in System Settings, where it can be changed, and it survives a
|
||||
komorebi process that has died. But it is one combo that runs one command: it cannot be in a
|
||||
mode, wait for the second key of a chord, fire on release, or do something else in each
|
||||
application. So a binding is a static shortcut when it is in the default mode, a single combo,
|
||||
unscoped and a press binding, and the file declares no modes; everything else goes through
|
||||
the engine, in which komorebi registers the keys itself and decides what each press does. A
|
||||
blacklist and a pause binding apply to every binding, so a file with either is the engine's
|
||||
too.
|
||||
|
||||
## Why does the engine handle every binding by default?
|
||||
|
||||
The plan was to make static shortcuts the default and to switch the default if a static
|
||||
shortcut turned out to be slow to start its command. It did: on KWin 6.8.1 (in a virtual
|
||||
machine, on 2026-10-27) a static shortcut ran its command 165 to 436 ms after the key, 233 ms
|
||||
at the median, while the engine was told of the key 3 ms after it. So the default is
|
||||
`PlanMode::Engine`, and `PlanMode::Auto` and `PlanMode::Static` stay selectable.
|
||||
|
||||
The cost is the robustness of static shortcuts: the engine works only while komorebi runs,
|
||||
and a komorebi process that was killed leaves its keys registered and dead until they are
|
||||
released.
|
||||
Reference in new issue
Block a user