Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch workspaces on keydown rather than on keyup #205

Closed
moritzuehling opened this issue Apr 23, 2024 · 4 comments
Closed

Switch workspaces on keydown rather than on keyup #205

moritzuehling opened this issue Apr 23, 2024 · 4 comments

Comments

@moritzuehling
Copy link

Is it possible to switch workspaces on key down rather than key up?

In general, this adds a lot of (perceived) latency. It's still slower than e.g. sway/hyprland on linux, but those WMs switch on keydown rather than keyup.

@nikitabobko
Copy link
Owner

nikitabobko commented Apr 23, 2024

It's not possible in the upstream binary, but you can build AeroSpace from sources with the following patch:

diff --git a/Sources/AppBundle/config/HotkeyBinding.swift b/Sources/AppBundle/config/HotkeyBinding.swift
index 04d0e45b..7aff4d49 100644
--- a/Sources/AppBundle/config/HotkeyBinding.swift
+++ b/Sources/AppBundle/config/HotkeyBinding.swift
@@ -24,7 +24,7 @@ var activeMode: String? = mainModeId
 func activateMode(_ targetMode: String?) {
     let targetBindings = targetMode.flatMap { config.modes[$0] }?.bindings ?? [:]
     for binding in targetBindings.values where !hotkeys.keys.contains(binding.binding) {
-        hotkeys[binding.binding] = HotKey(key: binding.key, modifiers: binding.modifiers, keyUpHandler: {
+        hotkeys[binding.binding] = HotKey(key: binding.key, modifiers: binding.modifiers, keyDownHandler: {
             if let activeMode {
                 refreshSession(forceFocus: true) {
                     _ = config.modes[activeMode]?.bindings[binding.binding]?.commands.run(.focused)

but those WMs switch on keydown rather than keyup

I tested other apps: i3-wm (on Linux), Chrome, Firefox, Finder, IntelliJ IDEA. I was genuinely surprised that all of them handle keydown. For some reason, I thought that apps normally handle keyup.

Since keydown seems to be the norm, I think I will change the default when I return from vacation (in 1 month)

@kevingyori
Copy link

I was just looking into how I could configure this, and tried out building from source with this patch.

It made switching between workspaces feel basically as fast as i3/sway. Awesome change!

nikitabobko added a commit that referenced this issue May 17, 2024
keyDownHandler seems to be the norm among apps
#205
nikitabobko added a commit that referenced this issue May 19, 2024
keyDownHandler seems to be the norm among apps
#205
@nikitabobko
Copy link
Owner

Fixed in 0.11.0-Beta

@moritzuehling
Copy link
Author

Thank you so much for this, this is absolutely awesome :)

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

No branches or pull requests

3 participants