ianyh / Amethyst

Automatic tiling window manager for macOS à la xmonad.
https://ianyh.com/amethyst/
MIT License
14.87k stars 487 forks source link

Can we have, leader key instead using Mod 1 Mod 2 #343

Open jiMuBao opened 9 years ago

jiMuBao commented 9 years ago

Can we user leader key like vim or tmux prefix (ctrl + b) instead mod1 or mod2 ?

Trello Card

ianyh commented 9 years ago

It's an interesting idea. I've toyed around with some ideas like this. Having something like a shortcut to bring up a prompt from which other commands can be run, or to visually switch layouts. A leader key kind of naturally falls out from that. It would also probably be a good way to clean up the command shortcut namespace, which just gets more and more cluttered as we introduce more commands.

The downside is that it might be something of a substantial departure from the current model, and would be difficult to get right without substantial customization of the shortcuts library in use. Not to say that it isn't possible, but it bears further discussion, I think.

brettneese commented 9 years ago

I would love this. Most of the time Amethyst acts like (I think) it should but that also means that anything beyond the basic commands I've taught myself requires looking at the docs.

I've currently got my Caps Lock acting as a meta-key via http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/, would love to map it to an Alfred-esque command line for Amethyst as well, or have it show an overlay of other commands I could run.

There's possibly a way to do this with just Karabriner, though.

MarioRicalde commented 5 years ago

I find the mod1 and mod2 key combination to be quite painful for me to use, mainly because of the fact I use an ErgoDox EZ. My spacebar is on my left-hand thumb cluster, and the keys that I have to use make me do a claw-like motion with my hand.

I notice that @ianyh marked this for discussion, so what do we have to discuss here to get the ball rolling for this one? I showed this to some co-workers and they loved the concept and what Amethyst brought in terms of functionality. They absolutely despised the mod1 and mod2 keycombos and I definitely agree with that sentiment.

ianyh commented 5 years ago

Having a leader key is a pretty big departure technically speaking because of how shortcuts are currently registered. It would be good to work out the details before trying to move forward with an implementation.

We use this library, which uses the common macOS mechanism for registering shortcuts. https://github.com/shpakovski/MASShortcut/

To have a leader key you can't use the same mechanism. In that case shortcuts can, for example, override existing global shortcuts, focused application shortcuts, and just general text interactions depending on where you are in an app. I've thought about ways to accomplish this, but the best I came up with is having a global shortcut that opens an Amethyst window that captures keyboard focus, at which point we can just use normal application shortcuts. As I said, though, this is a substantial departure from the current codebase. We would either have to support both mechanisms entirely separately or move entirely to using a leader key. I'm opposed to the latter, and I don't see a way around the former. I'm open to suggestions, though, which is why this needs discussion.

MarioRicalde commented 5 years ago

I think I understand the problem a bit better. As much as I'd like to be able to give some ideas in terms of implementation, this problem is not within my skillset; however, let me try to aid with direction...

Setting aside the project-specific problems (code), the most important question is:

If the answer is no, I bet it's because of a mountain of limitations from the OS itself. In which case it could be a dead end, and there's no discussion to be had here. Instead, this might create a new issue to figure out better key combinations.

ianyh commented 5 years ago

Yeah, finding any examples would be a great place to start.

I would hear an argument for different key combinations, but I would propose that being able to bulk change shortcuts might improve this.

brettneese commented 5 years ago

I don't need this as much anymore, but I'm clearing out my notifications and I'd like to point out that there is an excellent built-in leader mechanism: it's in international keyboards. If you set your keyboard to International Spanish, OSX will automatically turn the [ and ] keys into accent keys for the next key, and will even produce a little tick in the text box telling you it's doing that:

http://g.recordit.co/OeCqZ8RJVz.gif

I will say that the recently approved ability to rearrange windows by moving them has mostly solved this issue for me.

ianyh commented 5 years ago

I think that’s actually just a Unicode thing. It displays combining characters inline. It’s not a leader key in the sense of shortcuts.