nikitabobko / AeroSpace

AeroSpace is an i3-like tiling window manager for macOS
https://nikitabobko.github.io/AeroSpace/guide
MIT License
6.22k stars 101 forks source link

Add support of right-command key and left-command key #28

Open lknop opened 10 months ago

lknop commented 10 months ago

AeroSpace seems to intercept all shortcuts with Option key. However, in some international layouts Option is used to write accented letters (e.g. Ō, Ł). It would be great if there was an option to differentiate between left and right Option key, and match bindings only with one of them, passing the unmatched ones to the OS for default handling.

Note: I am using 0.5 beta.

nikitabobko commented 10 months ago

The same issue in Amethyst https://github.com/ianyh/Amethyst/issues/1091

wojciech-kulik commented 9 months ago

As a workaround, you can use skhd, a single line in the config:

lalt - l : aerospace focus right
GraemeARobinson commented 8 months ago

@wojciech-kulik, neat solution. Would be good if this was included in aerospace in future though but good to have a workaround

GraemeARobinson commented 8 months ago

Unfortunately this workaround doesn't work when secure input is enabled, which is sometimes enforced by running apps 😢

webskydavid commented 7 months ago

I also miss this feature. The only solution for me is to disable the AeroSpace when typing special letters.

webskydavid commented 7 months ago

Someone wanted to add this keys but it seems it does not work.

image
lknop commented 5 months ago

Due to this issue I stopped using Aerospace (and Mac altogether) for some time. However, I need to swtich to MacOS temporarily and having used i3 for quite some time I decided to figure out the solution. I saw the skhd workaround, though I was under the impression that Aerospace was intercepting the option key completely in that version. I haven't checked the code if anything changed in that area but in the latest version I got this to work (with a workaround) and since I am using karabiner with goku for my keyboard shortcuts, I will paste my version of the workaround.

karabiner.edn

:main [
     {:des "Change left_option to 3 modifiers combination, f17 when used alone"
         :rules [[:left_option :!COleft_control nil {:alone [:f17]}]]}
  ]

this remaps left option to alt-cmd-ctrl, which can then be used in Aerospace shortcuts, leaving right option as the default modifier for accented letters. I also had to modify other shortcuts from alt to alt-cmd-ctrl but the sample below should be enough to get started.

.aerospace.toml

alt-cmd-ctrl-1 = 'workspace 1'
alt-cmd-ctrl-2 = 'workspace 2'
alt-cmd-ctrl-3 = 'workspace 3'
alt-cmd-ctrl-4 = 'workspace 4'
alt-cmd-ctrl-5 = 'workspace 5'

alt-cmd-ctrl-shift-1 = 'move-node-to-workspace 1'
alt-cmd-ctrl-shift-2 = 'move-node-to-workspace 2'
alt-cmd-ctrl-shift-3 = 'move-node-to-workspace 3'
alt-cmd-ctrl-shift-4 = 'move-node-to-workspace 4'
alt-cmd-ctrl-shift-5 = 'move-node-to-workspace 5'

I think karabiner does not need Secure Input to be disabled. It would be awesome if Aerospace could differentiate between left and right modifier keys by itself so perhaps this issue should be left open for reference. But the workaround works well enough that my original problem is resolved.

tylercecil commented 4 months ago

Another workaround: I have a mode in aerospace which doesn't bind any keys, allowing me to easily "pause" aerospace.

cmd-semicolon = 'mode X'

[mode.X.binding]
# A mode to just pass keys through!
cmd-semicolon = 'mode main'
esc = 'mode main'
Bubobubobubobubo commented 3 months ago

Another workaround: I have a mode in aerospace which doesn't bind any keys, allowing me to easily "pause" aerospace.

I just tried this workaround to make Aerospace usable with my AZERTY keyboard. It works, but you have to always think about disabling the tiling manager whenever you type something. Note that I have remapped to alt-backspace to switch in and out of the special mode. This key-combo feels more natural (IMO) when your hands are resting in the center of the keyboard.

@nikitabobko : Is there a special reason preventing the detection of the l-alt r-alt keys? I don't have any knowledge of MacOS internals, just curious about it.

lknop commented 3 months ago

@Bubobubobubobubo the different modes is only one possible workaround, please read the whole thread, there are two more workarounds (with skhd and karabiner) that may be better suited for your use case.

olenderhub commented 2 months ago

Inspired by https://github.com/nikitabobko/AeroSpace/issues/28#issuecomment-2094850548

I created a config for Karabiner + init Aerospace config (including remapping left option to left command + left option + left control)

You can use this config from this repo

https://github.com/olenderhub/aerospace-config

esaibev commented 3 weeks ago

I used the workaround by @lknop (thanks!), but noticed that you're forced to always press left option before any other modifier for the command to work.

For instance, if you're using "shift-alt-cmd-ctrl-1" to move the node to workspace 1, it doesn't work if you press shift before left option.

I fixed this by adding the "optional any" modifier (##) before left option, like below:

{
  :des "Change left_option to 3 modifiers combo (rcmd, ralt, rctrl), f17 when used alone"
  :rules [
    [:##left_option :!QEright_control nil {:alone [:f17]}]
  ]
}

What the Karabiner rule looks like:

{
    "description": "Change left_option to 3 modifiers combo (rcmd, ralt, rctrl), f17 when used alone",
    "manipulators": [
        {
            "from": {
                "key_code": "left_option",
                "modifiers": { "optional": ["any"] }
            },
            "to": [
                {
                    "key_code": "right_control",
                    "modifiers": ["right_command", "right_option"]
                }
            ],
            "to_if_alone": [{ "key_code": "f17" }],
            "type": "basic"
        }
    ]
}
gagbo commented 2 weeks ago

Do we have any idea of what’s necessary to make this work? It’s a pretty important feature to me as well, and if I can hack something together I’ll try to take the time