koekeishiya / skhd

Simple hotkey daemon for macOS
MIT License
6.05k stars 204 forks source link

Add command to list possible hotkeys for current mode #130

Open davidisaaclee opened 4 years ago

davidisaaclee commented 4 years ago

Given the following skhdrc:

a : echo "do this"

:: mymode
ctrl - m ; mymode
mymode < a : echo "in mymode – do this"
mymode < b : echo "in mymode – do that"

I'd like to be able to perform something like the following commands:

# in default mode
# `--show-options` is a new command which prints the possible hotkeys for the current state of skhd.
$ skhd --show-options
a : echo "do this"

# user presses `ctrl - m` and enters `mymode`
$ skhd --show-options
mymode < a : echo "in mymode – do this"
mymode < b : echo "in mymode – do that"

Let me know if the behavior is not clear and I can try to explain more.

I'm looking for this kind of command to help me write a GUI helper that shows me what commands I can invoke. I could write this as a separate application, but it seems like I would need to maintain a separate parser, and I would need to be able to track skhd's active mode to return only the relevant results.

I think my ideal output for this command would be JSON corresponding to the hotkey struct to avoid needing any further parsing.

Is this something you would want in skhd? I don't have a lot of C experience, so I thought I would ask before taking time to dive in.

koekeishiya commented 4 years ago

This is reasonable, yes. I may have plans to revise both the syntax and a large part of the internal structure, so I don't think it would be beneficial for you to try and work this into the current master. Feel free to mess around if you want to learn how skhd works or enjoy this kind of work though.