mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-27 19:02:47 +01:00
feat(hotkeys): read an sxhkdrc
The third format is sxhkd's, the hotkey daemon users of tiling window managers
on X11 bind keys with. `sxhkd::parse` reads a hotkey line and the indented
command below it, with comments and continued lines, X keysyms (XF86 media keys
included) and the modifiers sxhkd shares with KDE.
Braces are expanded while reading, in the hotkey and the command together:
`{a,b}`, ranges such as `1-9`, `_` for nothing and `\{` for a literal brace,
with every combination of several pairs, the last changing fastest. A chord
chain (`super + w ; h`) is one binding with two combos, and a chain that stays
open after its last chord (`super + r : {h,l}`) is a mode named after its
prefix, entered by the prefix and left with Escape. `@` makes a release binding.
The diagnostics say what differs from sxhkd: a wrong key does not end a chain
(only Escape and the chord timeout do), a release binding fires on the first
key-up of any key of its combo, `~` does not pass the key on, and the modifiers
KDE has no equivalent for, mouse buttons and keypad keys are left out.
`parse` now picks the reader by format, and the corpus test reads every fixture
with it: the files of each case, in all three formats, read into the same
keymap.
This commit is contained in:
1 parent
dc9d12b34a
commit
e713d77272
6 files changed
+866
-32
No files matched your search
@@ -1599,6 +1599,11 @@ daemons: skhd (macOS), whkd (Windows) and sxhkd (X11).
|
||||
- [`whkd`](../../komorebi-hotkeys/src/whkd.rs): reads a whkdrc, in any order of its sections,
|
||||
where whkd requires one. `tests/whkd_parser.rs` compares it with whkd's own parser,
|
||||
`whkd-parser` (a dev-dependency), on every whkdrc of the corpus.
|
||||
- [`sxhkd`](../../komorebi-hotkeys/src/sxhkd.rs): reads an sxhkdrc. Braces are expanded first,
|
||||
into one binding per alternative. A chord chain (`a ; b`) is one binding with several combos;
|
||||
a chain that stays open (`a : b`) is a mode named after its prefix, entered by the prefix and
|
||||
left by Escape.
|
||||
- [`parse`](../../komorebi-hotkeys/src/lib.rs) picks the reader by format.
|
||||
- [`text`](../../komorebi-hotkeys/src/text.rs): what the readers share: line numbers, comments,
|
||||
continued lines and the diagnostics' wording.
|
||||
- [`tests/fixtures`](../../komorebi-hotkeys/tests/fixtures): the corpus, `<case>.skhdrc`,
|
||||
@@ -1613,8 +1618,8 @@ daemons: skhd (macOS), whkd (Windows) and sxhkd (X11).
|
||||
| Positional key names (macOS keycodes, `oem_*`) are read as on a US layout | convention only | none | none |
|
||||
| Reading a file returns a keymap, whatever the text | type system: a reader returns `Parsed`, not a `Result` | none | none |
|
||||
| Text that is left out has a diagnostic that points at it | test | `what_cannot_be_read_is_reported_and_left_out`, `reading_goes_on_after_an_error`, `diagnostics_point_at_the_text_they_are_about` | none |
|
||||
| A fixture reads, without errors, into the keymap of its case | test, for the skhdrc and whkdrc files; convention only for the others | `every_file_reads_without_errors_into_the_keymap_of_its_case` | none |
|
||||
| The files of a case read into the same keymap, apart from where each binding was written | test, for the skhdrc and whkdrc files | `the_files_of_a_case_read_into_the_same_keymap` | none |
|
||||
| A fixture reads, without errors, into the keymap of its case | test | `every_file_reads_without_errors_into_the_keymap_of_its_case` | none |
|
||||
| The files of a case read into the same keymap, apart from where each binding was written | test | `the_files_of_a_case_read_into_the_same_keymap` | none |
|
||||
| The whkd reader reads a whkdrc as whkd does | test, on the files it is given | `every_whkdrc_of_the_corpus_reads_as_whkd_reads_it`, `the_example_of_whkds_readme_reads_as_whkd_reads_it` | none |
|
||||
|
||||
## Where to look in the code
|
||||
@@ -1793,8 +1798,11 @@ daemons: skhd (macOS), whkd (Windows) and sxhkd (X11).
|
||||
komorebi.
|
||||
- [`komorebi-hotkeys/src/lib.rs`](../../komorebi-hotkeys/src/lib.rs): the key binding model,
|
||||
[`komorebi-hotkeys/src/qt.rs`](../../komorebi-hotkeys/src/qt.rs) the keys, and one module per
|
||||
format, [`skhd.rs`](../../komorebi-hotkeys/src/skhd.rs) and
|
||||
[`whkd.rs`](../../komorebi-hotkeys/src/whkd.rs).
|
||||
format, [`skhd.rs`](../../komorebi-hotkeys/src/skhd.rs),
|
||||
[`whkd.rs`](../../komorebi-hotkeys/src/whkd.rs) and
|
||||
[`sxhkd.rs`](../../komorebi-hotkeys/src/sxhkd.rs).
|
||||
- [`komorebi-hotkeys/tests`](../../komorebi-hotkeys/tests): the corpus test and the comparison
|
||||
with `whkd-parser`.
|
||||
- [`nix/nixos-module.nix`](../../nix/nixos-module.nix): the NixOS module;
|
||||
[`nix/tests/nixos-module.nix`](../../nix/tests/nixos-module.nix), its scenarios, evaluated in
|
||||
real NixOS systems; and [`nix/tests/vm/suites/module`](../../nix/tests/vm/suites/module/test.py),
|
||||
|
||||
+3
-3
@@ -719,6 +719,6 @@ komorebi, so it stays usable as a dev-dependency: a test reads every whkdrc of t
|
||||
corpus with both parsers and compares the bindings. For skhd and sxhkd the reason is not
|
||||
recorded; this entry needs one.
|
||||
|
||||
What is not plain syntax is expanded while the file is read: skhd's `.define` templates and
|
||||
application groups are replaced where they are used, so the model has only expanded bindings
|
||||
in it.
|
||||
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.
|
||||
Reference in new issue
Block a user