Skip to content

feat(macos): start working towards having shortcuts configuration#52

Open
nobe4 wants to merge 11 commits intonixosfrom
macos-shortcuts
Open

feat(macos): start working towards having shortcuts configuration#52
nobe4 wants to merge 11 commits intonixosfrom
macos-shortcuts

Conversation

@nobe4
Copy link
Copy Markdown
Owner

@nobe4 nobe4 commented Mar 25, 2026

This is inspired by https://github.com/nix-darwin/nix-darwin/pull/699/changes. It however simplifies the process by fixing all the "magic" values and only really needing to do basic addition for the mods and then string conversions.

The current state is: working, and now only need to specify the defaults.

As mentionned in
nix-darwin/nix-darwin#699 (comment), I will use defaults write com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add magicNumber "<dict></dict>" instead.

nobe4 added 11 commits March 25, 2026 12:14
This is inspired by https://github.com/nix-darwin/nix-darwin/pull/699/changes.
It however simplifies the process by fixing all the "magic" values and
only really needing to do basic addition for the mods and then string
conversions.

Currently it only outputs it to a file, next step is to start checking
if it actually works to run against the actual system.

As mentionned in
nix-darwin/nix-darwin#699 (comment), I
will use `defaults write com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add magicNumber "<dict></dict>"`
instead.
Currently it doesn't make the changes, but maybe on restart it will?
This is fun ok? I'm doing this to myself with enthusiasm!
nobe4 added a commit to nobe4/nix-darwin that referenced this pull request Mar 30, 2026
This adds support for configuring keyboard shortcuts directly into
nix-darwin. This is not a new idea, but this looks like the only
implementation that does it consistently, whilst introducing a very
large number of options whilst keeping the default values available.

This works by:
- Create a mapping of all mods / keys. See `keycodes.nix`.
  I decided here to have the 'decimal' + 'ascii' values hard-coded. This
  took a while to get, but should save on future "maths" to get them.
  The keycodes are ordered directly from the source header file for
  consistency. In the future, I might use an AI for this, as it's a
  "simple translation".
- Create a mapping of all* the available mappings and their default
  state/shortcuts. This enables a comprehensive list, ordered by
  Apple's sections. This also allows to "reset to defaults" if needed.
  Without a change, the default state/shortcuts will be used, which
  should create minimal friction for new users.
- Add a `disableAll` toggle in case you don't want any of the default
  shortcuts. This is my case and I was really happy to see that I could
  just yeet all the defaults out, to only enable the ones I want.

*: the list was compiled on my personal macbook, which is a 2020 intel
with the touchbar. So I might not have all the configuration options.
However it would be really easy to add new, since they all map to a
unique ID.

AFAIK, this is a good to go PR with no extra work needed. But I would
appreciate any feedback nevertheless.

This draws on inspiration from nix-darwin#699
and various online sources (commented in the code whenever necessary).

This is also a single commit that is a direct `cp` of the head of
nobe4/dotfiles#52, plus minor adjustments for
inclusion into this repo.

I use `nixfmt` extensively btw, hence the formatting. And until (if)
NixOS/nixfmt#91 is solved I will format all my
files 🤷.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant