rbreaves / kinto

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

GNOME input switching shortcut Ctrl+Space (Super+Space) doesn't work in terminals #742

Closed Oorgien closed 1 year ago

Oorgien commented 1 year ago

Describe the bug Hotkeys doesn't work in Ubuntu Temrinal.

Expected behavior I have installed kinto following all the instructions. However, none of the hotkeys provided in kinto.py file is working in Ubuntu terminal. I could customize hotkeys separately via terminal settings, but ctrl + space combination doesn't work in both turned off and turned on terminal hotkeys modes. Could you please help me at least configure keyboard layout switching?

Install Type: Bare Metal Distro: Ubuntu 22.04 DE: Gnome Branch: master Commit: git rev-parse --short HEAD

Logs and status if relevant

xkb

systemctl --user status keyswap

Unit keyswap.service could not be found.

journalctl --user-unit=keyswap.service -b

-- No entries --
RedBearAK commented 1 year ago

@Oorgien

I'm just a fellow Kinto user but I might be able to clarify a few things and help you figure out why it's not working. And I'm also on Ubuntu 22.04.

Questions:

The xkb method is kind of deprecated unless you need Kinto to work with remote desktop types of software. Maybe you were just following along with the outdated debug instructions while filling in the report? Kinto uses xkeysnail for quite a while now.

Generally the idea with Kinto is that no keyboard shortcuts should need to be changed within any particular application, as Kinto overlays new Mac-style shortcuts that map onto the existing shortcuts, for both system-wide shortcuts and a lot of specific application hotkeys. I'd advise resetting the terminal shortcuts back to defaults if you've messed with anything within the application preferences.

rbreaves commented 1 year ago

The xkb method is kind of deprecated unless you need Kinto to work with remote desktop types of software.

I need to post additional information on how to properly setup a systemctl service that will always select the proper raw keyboard input - I believe I fixed that awhile back on a local linux desktop of mine but I probably never shared that code. It fully resolves x11vnc though to always use the proper keyboard input that appears to change its /dev/input location with almost every reboot. Other than that the x11vnc patch I mention in the readme beats out the xkb method in every way because the current xkeysnail based codebase works with it normally.

I also need to clean up the patch and get it merged with x11vnc, atm they have accepted only half of the fix because I haven't cleaned up the other half to have full support added to x11vnc. (it needs the ability to optionally use raw input for the keyboard while still using an xinput based mouse, otherwise they both go raw and that is no good for the mouse)

I'd advise resetting the terminal shortcuts back to defaults if you've messed with anything within the application preferences.

Definite yes, if that is the case.

Oorgien commented 1 year ago

@RedBearAK

Thanks for timely answer! Sorry for being late with my answer (:

авг 22 23:49:33 oorgien-System-Product-Name systemd[1]: Started xkeysnail. авг 22 23:49:33 oorgien-System-Product-Name sudo[2746]: root : PWD=/ ; USER=root ; COMMAND=/bin/bash -c /usr/bin/xhost +SI:localuser:root && /home/oorgien/.config/kinto/killdups.sh && /usr/local/bin/xkeysnail --quiet --watch /home/oorgien/.config/kinto/kinto.py авг 22 23:49:33 oorgien-System-Product-Name sudo[2746]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=0) авг 22 23:49:33 oorgien-System-Product-Name sudo[2749]: localuser:root being added to access control list

RedBearAK commented 1 year ago

@Oorgien

That's odd. Service is working, you're in X11, there's a valid response to xprop, and the WM_CLASS is the same as on my system. So you're just using the usual Ubuntu terminal app, and everything should be working fine.

If you're using a recent Kinto config file, shortcuts like Shift+Cmd+Braces (Left_Brace, Right_Brace) should let you navigate between tabs in browsers, file managers and most terminals. Does that not work for you? On a PC keyboard that would be physical keys Shift+Alt+Braces, on an Apple keyboard it would be physical Shift+Cmd+Braces. Same physical locations on either keyboard.

When you say that Ctrl+Space is not working, are you referring to the physical keys Ctrl and Space, or are you referring to what the physical equivalent of Cmd+Space is getting mapped to, to mimic the Spotlight keyboard shortcut from macOS?

In other words, which keys are you actually pressing and what do you expect to happen when you press those keys?

Oorgien commented 1 year ago

@RedBearAK Shift+Alt+Braces is working in browsers on my pc keyboard.

I was reffering to physical keys Ctrl + Space that stands for changing keyboard layout to the differenct language. I am pressing Ctrl + Space physically and I am expecting language switching. It works everywhere I've been trying to use this shortcut, except for Terminal application. And changing shortcuts in kinto config file doesn't change anything.

RedBearAK commented 1 year ago

@Oorgien

Shift+Alt+Braces is working in browsers on my pc keyboard.

You don't say whether they work in the terminal, which would establish that generally speaking shortcuts in Kinto are working properly in terminals. But I'll just assume that most shortcuts are working properly for you in terminals.

I was reffering to physical keys Ctrl + Space that stands for changing keyboard layout to the differenct language. I am pressing Ctrl + Space physically and I am expecting language switching. It works everywhere I've been trying to use this shortcut, except for Terminal application. And changing shortcuts in kinto config file doesn't change anything.

Alright, I think maybe this is the root of the issue, and it is certainly confusing for anyone who doesn't know how the modifier keys get moved around in Kinto. This confused me for a long time. There are two different "modmaps" that permanently remap some of the modifier keys to different physical locations. One for "GUI" apps and a slightly different one for terminal apps.

With the main modifier remap, GUI apps have the Super/Win key moved to the physical Ctrl keys (on a PC keyboard). But, in terminal apps the physical Ctrl keys both become Control_L, or Left_Ctrl. In other words, there is no Super/Win key in terminals.

Fortunately, there is a way to reference the Left_Ctrl key, and remap the shortcut back to Super+Space. Which is the actual shortcut in GNOME's keyboard settings. Super+Space and Shift+Super+Space.

So now you should understand why the shortcut works on the physical Ctrl+Space keys in "GUI" apps, since the physical Ctrl key is actually Super/Win. And why it's failing in terminals, since there is no Super/Win key available, so terminals can't create the "real" shortcut that GNOME wants to see.

How to get it to work in terminals? Use "C" or "LC" and Space somewhere in the terminals block. At the moment the main block of shortcuts for terminals is at the very end of the Kinto config file (it may move up above the "General" block in the future).

Look for this line (there may be two lines that look like this, you want the one closer to the end of the config file that has lots of shortcuts inside):

define_keymap(re.compile(termStr, re.IGNORECASE),{
# lots of shortcuts
}, "terminals")

Anywhere between the two curly braces, place new lines like this, save the config and restart Kinto:

    K("LC-Space"):          K("Super-Space"),
    K("Shift-LC-Space"):    K("Shift-Super-Space"),

This will take the Left_Ctrl+Space that the terminal produces from those physical keys, and hand Super+Space over to GNOME (well, to X11).

I happen to have two input languages enabled myself and this adjustment is making the shortcut work for me in GNOME Terminal. It was only working in non-terminal apps before adding these lines.

@rbreaves

Since this is the correct physical shortcut for input switching in macOS, this is probably something we should integrate in the default Kinto config. There's also a conflict in VSCode that should probably be dealt with. The system-wide input selection function should probably take precedence. I'll have to check what exactly that shortcut is doing in VSCode and see what the shortcut for that function is on macOS.

RedBearAK commented 1 year ago

@rbreaves

The situation with physical Ctrl+Space in VSCodes, Sublime Text and IntelliJ is kind of weird. There are Super+Space shortcuts for each that map onto Ctrl+Space, and that's also the shortcut within VSCodium on macOS, so it's obviously meant to be on physical Ctrl+Space even on macOS. There's no mention of "Super" within the default shortcut settings of VSCode or VSCodium on either platform.

But if you have the input sources shortcut enabled on macOS it takes over even if you're in VSCodium.

So I'm actually not sure how to fix the conflict. Other than just disabling it. Maybe if someone enables the multi-language support in Kinto those shortcuts should be automatically disabled so they don't interfere with input switching.

🤷🏽‍♂️

Oorgien commented 1 year ago

@RedBearAK

Thank a lot!

K("LC-Space"):          K("Super-Space"),
K("Shift-LC-Space"):    K("Shift-Super-Space"),

These shortcuts are working quiet well for terminal. I've already tried this approach, but I've thought that actual hotkey should be on the right side and the mapped one should be on the left side.

RedBearAK commented 1 year ago

@Oorgien

thought that actual hotkey should be on the right side and the mapped one should be on the left side

I used to have the same problem. Keep in mind the modifier keys move to different physical locations earlier in the config file. That’s why it’s a little confusing which side is input or output.

For PC keyboard:

Physical keys: Ctrl Meta Alt Logical keys: Meta Alt Ctrl Mac equivalents: Ctrl Opt Cmd

Everywhere you see “RC” on the left side just think of it as the Command key. That’s one of the easiest things to remember.

RedBearAK commented 1 year ago

@rbreaves @Oorgien

If one of you can change the title of this issue to...

"GNOME input switching shortcut Ctrl+Space (Super+Space) doesn't work in terminals"

... it could conceivably be found much more easily by others who have the same problem.

Oorgien commented 1 year ago

@RedBearAK Thank you for clarification) There also was one problem with tmux copy/paste with mouse interaction enabled. Do you know how it can be fixed? The problem is that when I highlight text in tmux, it can't be pasted with Cmd + v hotkey.

RedBearAK commented 1 year ago

There also was one problem with tmux copy/paste with mouse interaction enabled. Do you know how it can be fixed? The problem is that when I highlight text in tmux, it can't be pasted with Cmd + v hotkey.

@Oorgien

I would open a new issue with information about that. I can confirm I see the same thing just trying to select some text in the terminal while tmux is running. But I'm not really familiar with tmux.

rbreaves commented 1 year ago

@RedBearAK Thank you for clarification) There also was one problem with tmux copy/paste with mouse interaction enabled. Do you know how it can be fixed? The problem is that when I highlight text in tmux, it can't be pasted with Cmd + v hotkey.

I am actually very familiar with this problem and while I don't have as good of a fix for it as iTerm2 tends to do for macOS users - which is to say the "yank" copy that tmux performs by default just simply hooks up to your terminal's clipboard on macOS IF you are using iTerm2 doesn't appear to happen normally with macOS's Terminal app nor any Linux or Windows based Terminal either.

There is a workaround however for Linux and Windows users and even the stock Terminal app from Apple and that is to know which key to hold down while you highlight with your mouse the text you want to copy. This varies however depending on application and OS - so you're mileage will vary some, but I can tell you which of the 3 or 4 keys you might want to hold down individually while trying to copy.

Tmux copy macOS - Terminal - Try holding down Fn while holding down the left click to copy text Windows - Windows Terminal - Hold down Shift while holding down the left click to copy text Linux - ?? Terminal app - Hold down either Alt, Shift or Ctrl while holding down the left click to copy text

I should note.. I may revisit whether or not this can be fixed as well as it is for iTerm2 - but that may very well be out of scope for Kinto itself, but maybe not.

Oorgien commented 1 year ago

@rbreaves

Thanks for comprehensive answer, I already knew about holding shift and simply copying text from terminal using Alt + C, but I was used to Mac OS tmux feature with shared tmux and system clipboard and I was wondering if I could use this feature in Ubuntu

rbreaves commented 1 year ago

I will try and come up with something for that as well still.