rbreaves / kinto

Mac-style shortcut keys for Linux & Windows.
http://kinto.sh
GNU General Public License v2.0
4.24k stars 212 forks source link

Switching between input language using "ctrl+cmd" doesn't work #827

Open ewh0 opened 10 months ago

ewh0 commented 10 months ago

I'm a Mac user who gets used to using "ctrl+space"/"cmd+space" to switch between multiple input languages on Mac. Now I start to work on Linux and I'm trying to keep this convention. Thanks to this amazing tool. I find most of things are working seamlessly by default, except for switching between multiple input languages.

Problem

With Kinto turned on, I tried to use “ctrl+space" sequence to switch between input languages in multiple different applications. Most of them won't work, including

Interestingly, the only application where this sequence works is the built-in Terminal

The ctrl+space is registered for the input language framework for switching between languages, see the screenshots image image image

Information

Install type: bare metal Distro: Linux Mint 21.2 (Debian/Ubuntu based) DE: Cinnamon

Physical keyboard: Apple Magic Keyboard (en-us) Kinto configuration: everything is left as default, except for the "Keyboard Type" which is explicitly set to "Apple"

RedBearAK commented 10 months ago

@ewh0

I'm not the Kinto dev, but I have been using it for a long time and used it as the basis for my own project (Toshy). This is a slightly complicated problem, with no perfect solution.

In non-terminal ("GUI") apps, Kinto moves the modifiers so that the physical Ctrl key is "Super" (other desktop environments like KDE will call the same key "Meta").

In Linux terminal apps the physical Ctrl key stays "LEFT_CTRL". So if the logical shortcut you need to activate is Super+Space, you must remap LC+Space back to Super+Space in a terminals-specific keymap.

The built-in terminals in apps like VSCode or Sublime Text cannot be distinguished from the main window, so they inherit the "GUI" modmaps. So the solution there will be depending on whether you want to remap keys in the built-in terminal using the internal configuration abilities of that specific app.

And, you don't want to step on the Cmd+Space shortcut, that uses "RC-Space" in the Kinto config file. The key next to the space bar is turned into "RIGHT_CTRL".

So figuring this out is a multi-step process.

In macOS the shortcuts are Ctrl+Space and Shift+Ctrl+Space. In GNOME they are Super+Space and Shift+Super+Space. So outside of terminal apps, it usually just works with Kinto's remapping of the modifiers. But GNOME uses IBus by default, and you're using fcitx in Cinnamon, which appears to have two different sets of shortcuts (one for switching input method "groups"). So you'll have to decide which of those sets of shortcuts you want to set to Super+Space/Shift+Super+Space. If you don't need the "group" switching shortcuts, I would disable them and set the others to use Super.

For terminals (but no built-in terminals) Kinto has an override keymap already, to fix some "wordwise" and tab navigation shortcuts, where you'd need to add remaps for the LC+Space/Shift+LC+Space shortcuts.

# Special overrides for terminals for shortcuts that conflict with General GUI block below.
define_keymap(re.compile(termStr, re.IGNORECASE),{
    K("Alt-Backspace"):           K("Alt-Shift-Backspace"), # Wordwise delete word left of cursor in terminals
    K("Alt-Delete"):              [K("Esc"),K("d")],      # Wordwise delete word right of cursor in terminals
    K("RC-Backspace"):          K("C-u"),               # Wordwise delete line left of cursor in terminals
    K("RC-Delete"):             K("C-k"),               # Wordwise delete line right of cursor in terminals
    ### Tab navigation
    K("RC-Shift-Left"):         K("C-Page_Up"),         # Tab nav: Go to prior tab (Left)
    K("RC-Shift-Right"):        K("C-Page_Down"),       # Tab nav: Go to next tab (Right)
},"Special overrides for terminals")

Here's how you would add the override:

# Special overrides for terminals for shortcuts that conflict with General GUI block below.
define_keymap(re.compile(termStr, re.IGNORECASE),{
    # Remap LEFT_CTRL back to Super for input switching
    K("LC-Space"):              K("Super-Space"),       # Input method switching (next)
    K("LC-Shift-Space"):        K("Super-Shift-Space"), # Input method switching (previous)
    # Wordwise overrides of GUI block for terminals
    K("Alt-Backspace"):         K("Alt-Shift-Backspace"), # Wordwise delete word left of cursor in terminals
    K("Alt-Delete"):            [K("Esc"),K("d")],      # Wordwise delete word right of cursor in terminals
    K("RC-Backspace"):          K("C-u"),               # Wordwise delete line left of cursor in terminals
    K("RC-Delete"):             K("C-k"),               # Wordwise delete line right of cursor in terminals
    ### Tab navigation
    K("RC-Shift-Left"):         K("C-Page_Up"),         # Tab nav: Go to prior tab (Left)
    K("RC-Shift-Right"):        K("C-Page_Down"),       # Tab nav: Go to next tab (Right)
},"Special overrides for terminals")

Exactly how you resolve this for the different aspects of your situation is kind of up to you.