Skip to content

Conversation

@Miigon
Copy link

@Miigon Miigon commented Jul 7, 2023

Fixes #174 #6 #280 #226 #194

looks like this:

.alias $hyper cmd + alt + ctrl
.alias $capslock 0x39
.alias $exclamation_mark shift - 1
.alias $terminal_key $hyper + shift - t

# alias as modifier
$hyper - t : open -a Terminal.app

# alias as key
ctrl - $capslock : open -a Notes.app

# alias as mod-key
$hyper - $exclamation_mark : open -a "System Preferences.app"

# alias within alias
$terminal_key : open -a Terminal.app

Simplifying keymaps with eg. hyper keys. Easier to manage configuration.

This PR also:

  • fixed some memory leaks
  • reduced code duplication (parse_hotkey and parse_keypress.)
  • made skhd -k exit with -1 when failed to parse.
  • made skhd --verbose -k respect --verbose (do not close stdout/stderr when in verbose)

This new feature technically deprecates some keycode literals like meh and hyper, however they're still kept for backward compatibility.

@Miigon
Copy link
Author

Miigon commented Jul 8, 2023

After some looking-around, it seems like this repo is not actively accepting changes and PRs.

I've decided to close this PR and create a new fork to experiment with some more new feature ideas (which might break compatibility, that's why I'm forking.)

Some more highly requested features here might also be "stolen" and implemented on that fork, I hope you wouldn't mind that.

I see the new fork as a more evolving version of skhd, with new (incompatible) config syntaxes & semantics and more features. And the original version of skhd can keep being the more stable and compatible alternative for users who don't want to switch and rewrite their config.

This way, we can take away the heavy lifting of supporting skhd and adding new features from you, without breaking anything for old users.

Thanks for your great work on skhd!

@Miigon Miigon closed this Jul 8, 2023
@tigger04
Copy link

tigger04 commented Jul 9, 2023

I am extremely interested in this. Can you link to the fork? Thank you for your work on this @Miigon :)

@Miigon
Copy link
Author

Miigon commented Jul 17, 2023

@tigger04

Update:
this is the fork: https://github.com/Miigon/mkhd

Redesigned a large portion of the parsing procedures and added new features (aliases, layers, keydown/keyup binding, builtin key synthesizing with non-recursive support, etc)

Some features are not yet finalized and many are yet to come. the syntax and semantics are not final either. The only document right now is an example configuration. Take a look and let me know what you think.

The short-term plan is to add highly requested features from skhd issues, then finalize the syntaxes and documentation before releasing the first version.

@asmvik
Copy link
Owner

asmvik commented Jul 18, 2023

I don't mind what you are doing, but I personally do not think this codebase is worth iterating on. It is better to start from scratch, and if you need to know how some specific macOS things work, look at how it was done here for inspiration as the documentation for said APIs are rather lackluster.

erics118 added a commit to erics118/skhd that referenced this pull request Sep 5, 2023
@tigger04
Copy link

tigger04 commented Aug 27, 2025

Did it get merged? Bit confused, as I tried it out and got

error(skhd): skhd: /Users/whata.user.config/skhd/skhdrc:5:1: error: Unknown option 'alias'. Valid options are: define, load, blacklist, shell near 'alias'
error: ParseErrorOccurred

At the moment I'm using a rather convoluted script that does a sed of all my personal aliases to generate a config file.
I just moved to koekeishiya/skhd from the old version (finally) and thought I would give this a try as it looked merged?

@Miigon really tempted by your fork but it looks a little inactive? And no homebrew formula. But I get it, a fork is a lot to take on :)

If there's a better way to do it with the new skhd? basically i rely heavily on ...

hypertig=rcmd + rctrl + ralt
hypershift=lshift + rcmd + rctrl + ralt
f20=0x5A
section=0x5A
spacebar=0x31
space=0x31
backslash=0x2A
opensqbracket=0x21
closesqbracket=0x1E
slash=0x2C
comma=0x2B
return=0x24

jackielii pushed a commit to jackielii/skhd.zig that referenced this pull request Nov 18, 2025
Implements key aliases feature allowing users to define reusable names
for modifiers, keys, and key combinations, making configs more readable
and maintainable.

Features:
- Three alias types: modifier, key, and keysym
- Full recursive expansion at parse time (zero runtime overhead)
- Circular reference detection with helpful error messages
- Nested alias support (aliases can reference other aliases)
- Compatible with existing syntax (modifiers combine like hyper/meh)

Syntax:
  .alias $super cmd + alt           # Modifier alias
  .alias $grave 0x32                # Key alias
  .alias $nav_left $super - h       # Keysym alias

Usage:
  $super - t : command              # Use modifier alias
  ctrl - $grave : command           # Use key alias
  $nav_left : command               # Use keysym standalone
  ctrl + $nav_left : command        # Add modifiers to keysym

Implementation:
- Tokenizer: Added Token_Alias for $identifier syntax
- Parser: Added Alias union type with storage and resolution logic
- Comprehensive error messages for type mismatches and undefined aliases
- Full test coverage for all alias types and error cases
- Documentation in SYNTAX.md and README.md with examples

Inspired by asmvik/skhd#288
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.

Cutom key definitions / add rhyper

3 participants