karabiner-windows-mode
karabiner-windows-mode copied to clipboard
refactor and fix minor issues
I find myself completely lost while trying to navigate windows_shortcuts.jsonnet
. Effort has already been made to remove boilerplate (bundle.standard
/ file_paths.standard
), I just took it one step further. Rather than defining standards in lib/{bundles,file_paths}.libsonnet
, I define them in windows_shortcuts.jsonnet
. This replaces dozens of identical function calls with a variable instead.
Then I rearranged all the rules so that rules with the same condition are grouped together. Once that was done I could finally read the file, and I noticed some things:
- there are a few rules that have no condition, but there's nothing in their names to distinguish them from rules which follow the standard condition. Every other deviation from the standard condition has had a special label, so I added the suffix
[Always]
to those rules. - the rule
Tab (Alt) [+IDEs and Terminal Emulators]
should be namedTab (Alt) [+IDEs, Remote Desktops, and Terminal Emulators]
- there are two bundles for google chrome, capitalized and lowercase, but only one bundle listed in the
[Only Chrome]
rules. - the ctrl+shift+(home/end) rules don't work because the home/end rules have
"any"
optional modifiers, so they take priority. I moved the ctrl/shift/(ctrl+shift) rules up in the list so that the more specific rules take priority.
this patch looks rather daunting, but 99% of the differences are just sorting. By enabling, running, disabling, and reverting the "render JSON" CI, and using jq
to sort the rules by description, I can show that the "refactor" commit didn't actually change anything in the result.
$ sha1sum <(git show 969a4d1:json/windows_shortcuts.json | jq '.rules | sort_by(.description)') <(git show 7a9e1f:json/windows_shortcuts.json | jq '.rules | sort_by(.description)')
b476280a8aadb16e56120139067de86af02548ae /dev/fd/63
b476280a8aadb16e56120139067de86af02548ae /dev/fd/62
where 7a9e1f
is the commit hash made below by the CI: [AUTO] Render JSON