RedBearAK / toshy

Keymapper config to make Linux work like a 'Tosh!
https://toshy.app
GNU General Public License v3.0
348 stars 16 forks source link

[BUG] Gnome Wayland meta key mapped to control #348

Closed CubeOfCheese closed 2 months ago

CubeOfCheese commented 2 months ago
``` Bare metal or virtual machine: (If in VM, which VM software): HP Probook (Try running 'toshy-env' in a terminal to fill out the following fields...) DISTRO_ID = 'fedora' DISTRO_VER = '40' VARIANT_ID = 'kde' SESSION_TYPE = 'wayland' DESKTOP_ENV = 'gnome' DE_MAJ_VER = '46' Keyboard type (IBM, Chromebook, Windows, Apple): HP Windows Keyboard device name (try 'toshy-devices'): ``` /dev/input/event3 AT Translated Set 2 keyboard isa0060/serio0/input0 * * * Problem observed: In GNOME, the meta key opens the workspace switcher and tapping it twice opens the app menu. After enabling toshy, that is now mapped to the control key. I expected it to either be mapped to the physical alt key (virtual command key) or to command+space (the former is my preference but this one aligns with the mac shortcut more). The reason I use toshy in the first place is to avoid having to reach for the control key, but since this action is so important in gnome, I'm having to reach for it a lot. I would love to see more settings so I can customize/remap stuff like this but I know that would be a lot of work for you. Please let me know if there's anything I can change on my end. Thanks for toshy. I love it.
RedBearAK commented 2 months ago

Any recent version of Toshy should have disabled the overlay-key shortcut that gets invoked by Meta/Super/Win, and sort of replaced it with a remap from Cmd+Space to the Overview shortcut. So we'd need to figure out why that's not happening for you.

This is a tricky subject, since every desktop environment tends to do something different to open up a launcher or app menu of some kind. For a while after GNOME 45 came out, I remapped Cmd+Space to LEFT_META, but leaving it like that and leaving the Super key shortcut enabled was problematic with certain shortcuts that need to work from the physical Ctrl key.

A fundamental thing to understand with the way the configuration file works is that the key next to the Space bar always becomes RIGHT_CTRL so that a bunch of Linux shortcuts "just work" without a ton of extra explicit remaps in the config. It's a bit confusing, and I didn't come up with this strategy (it came from Kinto), but I have also never found a better way to do things.

You may have also noticed that the Meta/Super key disappears when you're in a terminal app.

If you installed Toshy from a new zip in just the last few days, there should be a toshy-debug alias, otherwise there is the older alias to see the verbose debugging output:

toshy-config-verbose-start

If you run that, wait several seconds for the keymapper config to fully start, and then do Cmd+Space, a block of log output that looks a bit different should appear, and reveal what the Cmd+Space shortcut is doing. It would look something like this:

(II) in LEFT_ALT (press)
(CX) KDE_DBUS_SVC: Using D-Bus interface 'org.toshy.Plasma' for window context
(DD) KBTYPE: 'Windows' | (CACHED) Rgx matched on dev: 'AT Translated Set 2 keyboard'
(DD) MODMAP: LEFT_ALT => RIGHT_CTRL [Cond modmap - Terms - Win kbd]
(DD) on_key RIGHT_CTRL press
(DD) suspending keys: [VCmd<Key.RIGHT_CTRL>]

(II) in SPACE (press)
(CX) KDE_DBUS_SVC: Using D-Bus interface 'org.toshy.Plasma' for window context
(DD) on_key SPACE press
(DD) KBTYPE: 'Windows' | (CACHED) Rgx matched on dev: 'AT Translated Set 2 keyboard'

(DD) WM_CLASS: 'org.kde.konsole' | WM_NAME: 'wlroots-dev : bash — Konsole'
(DD) DEVICE: 'AT Translated Set 2 keyboard' | CAPS_LOCK: 'False' | NUM_LOCK: 'False'
(DD) ACTIVE KEYMAPS:
     'User hardware keys', 'Currency character overlay', 'User overrides: KDE',
     'Wordwise - not vscode', 'Konsole tab switching', 'Konsole terminal - not
      … tab nav', 'GenTerms overrides: Ubuntu/Fedora', 'GenTerms overrides: KDE',
     'General Terminals', 'GenGUI overrides: not Chromebook', 'GenGUI overrides:
      … KDE', 'General GUI', 'Diagnostics'
(DD) COMBO: VCmd-SPACE => [<function iEF2.<locals>._is_Enter_F2 at 0x7f35691879c0>, Alt-SPACE] in KMAP: 'GenGUI overrides: KDE'
(DD) spent modifiers [<Key.RIGHT_CTRL: 97>]
(DD) resuspending keys
(DD) suspending keys: [VCmd<Key.RIGHT_CTRL>]
(DD) _is_Enter_F2:  combo_list      = [None]
(DD) _is_Enter_F2:  _enter_is_F2    = True
(DD) resuspending keys
(DD) suspending keys: [VCmd<Key.RIGHT_CTRL>]
(OO) press LEFT_ALT 1722534703.5935366
(OO) press SPACE 1722534703.6239722
(OO) release SPACE 1722534703.6302166
(OO) release LEFT_ALT 1722534703.6605608
(DD) resuming keys: [<Key.RIGHT_CTRL: 97>]
(OO) press RIGHT_CTRL 1722534703.6821408

(II) in SPACE (release)
(CX) KDE_DBUS_SVC: Using D-Bus interface 'org.toshy.Plasma' for window context
(DD) on_key SPACE release

(II) in LEFT_ALT (release)
(CX) KDE_DBUS_SVC: Using D-Bus interface 'org.toshy.Plasma' for window context
(DD) on_key RIGHT_CTRL release
(DD) resume because of mod release
(OO) release RIGHT_CTRL 1722534703.7679563

Yours would look a bit different since I'm in KDE Plasma 6.

The question is also if you need the "app menu" screen. When I am using GNOME, I typically install something like Ulauncher, and set up a shortcut for ulauncher-toggle that I can remap Cmd+Space onto. And a second one for Alt+Space, so that whether I had Toshy enabled or disabled, I'd still see Ulauncher when hitting those physical keys (this only works on a PC keyboard, where the key next to Space is Alt).

We should be able to find something that works for you. We just need to find out what your Cmd+Space is doing right now.

There's also a Wiki article about customizing the Cmd+Space shortcut (and other shortcuts).

https://github.com/RedBearAK/toshy/wiki/How-to-(persistently)-change-the-Cmd-Space-remap

CubeOfCheese commented 2 months ago
teacher@fedora:~$ toshy-config-verbose-start

Stopping Toshy systemd services...

Toshy systemd services stopped.

xwaykeyz v1.0.1
(DD) CONFIG: /home/teacher/.config/toshy/toshy_config.py
(DD) THROTTLES: Pre-key: 12ms, Post-key: 18ms
(DD) No Synergy log folder found. No log observer will be engaged.

(CG) Current settings:
        -------------------------------------------
        calling_module          = 'toshy_config.py'
        prefs_db_file_path      = '/home/teacher/.config/toshy/toshy_user_preferences.sqlite'
        -------------------------------------------
        autostart_tray_icon     = True
        gui_dark_theme          = True
        -------------------------------------------
        override_kbtype         = 'Auto-Adapt'
        -------------------------------------------
        optspec_layout          = 'US'
        -------------------------------------------
        forced_numpad           = True
        media_arrows_fix        = False
        multi_lang              = False
        Caps2Cmd                = False
        Caps2Esc_Cmd            = False
        Enter2Ent_Cmd           = False
        ST3_in_VSCode           = False
        -------------------------------------------

(CG) Toshy config sees this environment:
        DISTRO_ID        = 'fedora'
        DISTRO_VER       = '40'
        SESSION_TYPE     = 'wayland'
        DESKTOP_ENV      = 'gnome'
        DE_MAJ_VER       = '46'

(DD) ENVIRON: Session type: 'wayland', Desktop env: 'gnome'
(DD) Zenity command path: '/usr/bin/zenity'
(--) WATCH: Watching for new devices to hot-plug.
(--) Autodetecting all keyboards (--device not specified)
(+K) Grabbing 'AT Translated Set 2 keyboard' (/dev/input/event3)
(+K) Successfully grabbed 'AT Translated Set 2 keyboard' (/dev/input/event3)
(--) Ready to process input.

(II) in LEFT_ALT (press)
(EE) D-Bus error querying GNOME Shell extension 'xremap@k0kubun.com':
        org.freedesktop.DBus.Error.UnknownMethod: 
         Object does not exist at path “/com/k0kubun/Xremap”
(EE) D-Bus error querying GNOME Shell extension 'window-calls-extended@hseliger.eu':
        org.freedesktop.DBus.Error.UnknownMethod: 
         Object does not exist at path “/org/gnome/Shell/Extensions/WindowsExt”
(DD) SHELL_EXT: Using UUID 'focused-window-dbus@flexagoon.com' for window context
(DD) KBTYPE: 'Windows' | Rgx matched on dev: 'AT Translated Set 2 keyboard'
(DD) MODMAP: LEFT_ALT => RIGHT_CTRL [Cond modmap - Terms - Win kbd]
(DD) on_key RIGHT_CTRL press
(DD) suspending keys: [RCtrl<Key.RIGHT_CTRL>]

(II) in SPACE (press)
(DD) SHELL_EXT: Using UUID 'focused-window-dbus@flexagoon.com' for window context
(DD) on_key SPACE press
(DD) KBTYPE: 'Windows' | (CACHED) Rgx matched on dev: 'AT Translated Set 2 keyboard'

(DD) WM_CLASS: 'org.kde.konsole' | WM_NAME: '~ : bash — Konsole'
(DD) DEVICE: 'AT Translated Set 2 keyboard' | CAPS_LOCK: 'False' | NUM_LOCK: 'True'
(DD) ACTIVE KEYMAPS:
     'User hardware keys', 'Wordwise - not vscode', 'Konsole tab switching',
     'Konsole terminal - not tab nav', 'GenTerms overrides: Fedora GNOME',
     'GenTerms overrides: Ubuntu/Fedora', 'GenTerms overrides: GNOME', 'General
      … Terminals', 'GenGUI overrides: not Chromebook', 'GenGUI overrides: Fedora
      … GNOME', 'GenGUI overrides: GNOME', 'General GUI', 'Diagnostics'
(DD) COMBO: RCtrl-SPACE => [<function iEF2.<locals>._is_Enter_F2 at 0x7f35fb351440>, Shift-Ctrl-SPACE] in KMAP: 'GenGUI overrides: GNOME'
(DD) spent modifiers [<Key.RIGHT_CTRL: 97>]
(DD) resuspending keys
(DD) suspending keys: [RCtrl<Key.RIGHT_CTRL>]
(DD) _is_Enter_F2:  combo_list      = [None]
(DD) _is_Enter_F2:  _enter_is_F2    = True
(DD) resuspending keys
(DD) suspending keys: [RCtrl<Key.RIGHT_CTRL>]
(OO) press LEFT_SHIFT 1722536882.172658
(OO) press LEFT_CTRL 1722536882.1727033
(OO) press SPACE 1722536882.1849263
(OO) release SPACE 1722536882.1851356
^@(OO) release LEFT_CTRL 1722536882.203389
(OO) release LEFT_SHIFT 1722536882.2035658

(II) in SPACE (release)
(DD) SHELL_EXT: Using UUID 'focused-window-dbus@flexagoon.com' for window context
(DD) on_key SPACE release

(II) in LEFT_ALT (release)
(DD) SHELL_EXT: Using UUID 'focused-window-dbus@flexagoon.com' for window context
(DD) on_key RIGHT_CTRL release
(DD) silent lift of spent mod RIGHT_CTRL

(II) in LEFT_CTRL (press)
(DD) SHELL_EXT: Using UUID 'focused-window-dbus@flexagoon.com' for window context
(DD) KBTYPE: 'Windows' | (CACHED) Rgx matched on dev: 'AT Translated Set 2 keyboard'
(DD) MODMAP: LEFT_CTRL => LEFT_CTRL [Cond modmap - Terms - Win kbd]
(DD) on_key LEFT_CTRL press
(DD) suspending keys: [LCtrl<Key.LEFT_CTRL>]

(II) in C (press)
(DD) SHELL_EXT: Using UUID 'focused-window-dbus@flexagoon.com' for window context
(DD) on_key C press
(DD) KBTYPE: 'Windows' | (CACHED) Rgx matched on dev: 'AT Translated Set 2 keyboard'
(DD) resuming keys: [<Key.LEFT_CTRL: 29>]
(OO) press LEFT_CTRL 1722536884.5960968
(OO) press C 1722536884.5961475

(II) in LEFT_CTRL (release)
(DD) SHELL_EXT: Using UUID 'focused-window-dbus@flexagoon.com' for window context
(DD) on_key LEFT_CTRL release
(DD) resume because of mod release
(OO) release LEFT_CTRL 1722536884.597721
^Csignal INT received
(OO) release C 1722536884.5989695
(-K) Ungrabbing: 'AT Translated Set 2 keyboard' (removed)
teacher@fedora:~$ 

This includes ctrl+c command I used to stop the debugger

RedBearAK commented 2 months ago

One of the problems with the way GNOME handles the overlay-key shortcut is that it takes a special hack in the shell to even allow a modifier key to be used by itself, without interfering with the same modifier key being used in combo shortcuts. This is pretty much always a problem when any desktop environment tries to use modifier-only shortcuts, including Plasma, where I have to disable the Meta key shortcut assigned to the app launcher menu.

There are also people who have unusual keyboards or combinations of keyboards, who wish they could use both the left and right Super keys, but only one can be enabled at a time.

https://gitlab.gnome.org/GNOME/mutter/-/issues/1277

So for a bunch of other shortcuts to work correctly, the modifier-only shortcut really has to be disabled in most cases. That means the solution might not be perfect.

So this shortcut:

(DD) COMBO: RCtrl-SPACE => [<function iEF2.<locals>._is_Enter_F2 at 0x7f35fb351440>, Shift-Ctrl-SPACE] in KMAP: 'GenGUI overrides: GNOME'

Is your Cmd+Space, remapping onto Shift+Ctrl+Space. But in more recent versions of the config file, that RCtrl-SPACE would now show as VCmd-SPACE (virtualized Command alias). So you definitely have a version of the Toshy config that's a bit older.

Nevertheless, if you had a shortcut set up in your GNOME keyboard settings control panel, to "Show Overview" with Shift+Ctrl+Space, that remap should work to at least open up the Overview. (From which you can search for apps to launch, sort of like Spotlight).

If nothing else works for you, you can still leave the overlay-key enabled and do an override to make Cmd+Space issue Key.LEFT_META. However I can't recall ever trying to get to the app menu screen by using that remap.

On a laptop I would often use the trackpad swipe gestures to get to those screens.

RedBearAK commented 2 months ago

I've also made some substantial performance improvements in just the last couple of months, and you definitely don't have those enhancements available if you still have this version of the keymapper installed:

xwaykeyz v1.0.1

A re-install of Toshy from a new zip will install a significantly reworked config file and v1.3.1 of the keymapper. You probably would not notice much changing besides the lowered CPU usage of the config.

CubeOfCheese commented 2 months ago

I installed the newest version and it just works as expected now with command+space. Thank you

RedBearAK commented 2 months ago

works as expected now with command+space

Oh. Fantastic. I was expecting to still need to troubleshoot a bit, but if it does what you want now, great. 👍🏽

Might want to grab a new zip and do it again, because I just merged in a fix for a misbehaving script, but its behavior would probably never affect you if you only use GNOME and never log into a wlroots-based Wayland window manager like Hyprland/Qtile, so not a big deal either way.

RedBearAK commented 2 months ago

I'm going to go ahead and close this out, since it seems to be resolved. Feel free to open other issues.