wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
18.18k stars 813 forks source link

macOS menubar key shortcuts for shifted keys are tricky to override #3508

Open eproxus opened 1 year ago

eproxus commented 1 year ago

What Operating System(s) are you seeing this problem on?

macOS

Which Wayland compositor or X11 Window manager(s) are you using?

No response

WezTerm version

20230411-221643-c8b8e811

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

Before WezTerm had a menubar I had the following key bindings working:

{ key = '}', mods = 'SUPER|SHIFT', action = act.SendString '\x02\x6e' },
{ key = '{', mods = 'SUPER|SHIFT', action = act.SendString '\x02\x70' },

Which were sending commands to tmux. Now with the new menu bar, I can't seem to be able to override them properly. First of all, they don't work anymore.

If I look in the menu bar for the entry WindowSelect TabActivate the tab to the right it is now bound to ]. If I try to override that:

{ key = ']', mods = 'SUPER|SHIFT', action = act.SendString '\x02\x6e' },

the key in the menubar suddenly flips to ], but on my keyboard ] and } are the same key, just that } is being generated when the modifier is pressed. The menu bar seems to take precedence over my custom binding.

If I add both entries, the menu item suddenly flips to } and still triggers instead of my own bindings!

The only way I can reliably make it work is by having all three items (!):

{ key = '}', mods = 'SUPER', action = act.SendString '\x02\x6e' },
{ key = '}', mods = 'SUPER|SHIFT', action = act.SendString '\x02\x6e' },
{ key = ']', mods = 'SUPER|SHIFT', action = act.SendString '\x02\x6e' },

(And then for some reason the menu item changes to which hopefully doesn't break anything else).

To Reproduce

  1. Use config below
  2. Try to rebind keys belonging to the menu bar items

Configuration

return {
  keys = {
    -- Tmux (macOS)
    { key = '}', mods = 'SUPER|SHIFT', action = act.SendString '\x02\x6e' },
    { key = '{', mods = 'SUPER|SHIFT', action = act.SendString '\x02\x70' }
  }
}

Expected Behavior

I would expect my old config to work, or at least to be able to rebind one menu bar key binding to my own custom behaviour.

Logs

No response

Anything else?

No response

dinvlad commented 1 year ago

Have you found a solution, by any chance? I've posted about a similar problem here, and then found your issue: https://github.com/wez/wezterm/discussions/4237

eproxus commented 1 year ago

For my case I use the following workaround:

return {
  keys = {
    { key = ']', mods = 'SUPER', action = act.SendString '\x02\x6f' },
    { key = '[', mods = 'SUPER', action = act.SendString '\x02\x4f' },
    { key = ']', mods = 'SUPER|SHIFT', action = act.SendString '\x02\x6e' },
    { key = '}', mods = 'SUPER', action = act.SendString '\x02\x6e' },  -- Bug in WezTerm
    { key = '}', mods = 'SUPER|SHIFT', action = act.SendString '\x02\x6e' },  -- Bug in WezTerm
    { key = '[', mods = 'SUPER|SHIFT', action = act.SendString '\x02\x70' },
    { key = '{', mods = 'SUPER', action = act.SendString '\x02\x70' },  -- Bug in WezTerm
    { key = '{', mods = 'SUPER|SHIFT', action = act.SendString '\x02\x70' },  -- Bug in WezTerm
  }
}