RedBearAK / toshy

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

(Question) Switching Workspaces Left and Right in Fedora Gnome #322

Open denppa opened 1 month ago

denppa commented 1 month ago

Installed toshy via setup_toshy.py install, and tried to mimic MacOS's behavior of switching to the right and left workspace via '<Control>Right' and '<Control>Left', but it did not work as expected. Instead, '<Control>Right' went to the left and '<Control>Left' went to the right.

Looking up dconf, it seems that I needed to do it via '<Super><Alt>Right' or '<Control><Alt>Right', is there a way to change this to '<Control>Right' are does it conflict with other mappings and is therefore impossible?

Thank you.

Environment

RedBearAK commented 1 month ago

Looks like this has changed in recent versions of macOS:

https://apple.stackexchange.com/questions/362614/macos-navigating-between-desktops-using-keyboard-shortcuts

I'm not really familiar with the macOS shortcuts for this since I was never a big "Spaces" or workspace user. But you should be able to remap what you are used to using, onto the native shortcuts for any particular desktop environment (they aren't standard across DEs).

You're in GNOME, so I'll give you a keymap that will be targeted at GNOME, and we'll put this in a custom safe spot just for your config, then look at maybe making it part of the default config file if ti works out well.

You'll want to open up your config file in any plain text editor or code editor like GNOME Text Editor or Visual Studio Code.

The file is located at ~/.config/toshy/toshy_config.py. A quick way to get the folder open is from the tray icon menu item "Open Config Folder".

In the config file, search for this string: user_apps

That tag is on a marked "slice" where it's safe to put customizations and they will be protected even if you reinstall or upgrade Toshy. You want any custom edits of the config in one of those marked slices.

By default that slice is pretty much empty, with an example keymap to put some hardware keys into:

####################################  USER APPS  #####################################
###                                                                                ###
###                                                                                ###
###      ██    ██ ███████ ███████ ██████       █████  ██████  ██████  ███████      ###
###      ██    ██ ██      ██      ██   ██     ██   ██ ██   ██ ██   ██ ██           ###
###      ██    ██ ███████ █████   ██████      ███████ ██████  ██████  ███████      ###
###      ██    ██      ██ ██      ██   ██     ██   ██ ██      ██           ██      ###
###       ██████  ███████ ███████ ██   ██     ██   ██ ██      ██      ███████      ###
###                                                                                ###
###                                                                                ###
######################################################################################
### This is a good location in the config file for adding new custom keymaps for 
### user applications and custom function keys. Watch out that you don't override 
### any "general" shortcuts like Cmd+Z/X/C/V that may be defined below this section. 
### Changes made between the "slice" marks will be retained by the Toshy installer 
### if you reinstall and it finds matching start/end markers for each section. 

###################################################################################################
###  SLICE_MARK_START: user_apps  ###  EDITS OUTSIDE THESE MARKS WILL BE LOST ON UPGRADE

keymap("User hardware keys", {
    # PUT UNIVERSAL REMAPS FOR HARDWARE KEYS HERE
    # KEYMAP WILL BE ACTIVE IN ALL DESKTOP ENVIRONMENTS/DISTROS

}, when = lambda ctx:
    cnfg.screen_has_focus and
    matchProps(not_lst=remotes_lod)(ctx)
)

###  SLICE_MARK_END: user_apps  ###  EDITS OUTSIDE THESE MARKS WILL BE LOST ON UPGRADE
###################################################################################################

Inside those slice marks add a new pair of keymaps inside an if block, just like this (copy/paste it):

###################################################################################################
###  SLICE_MARK_START: user_apps  ###  EDITS OUTSIDE THESE MARKS WILL BE LOST ON UPGRADE

keymap("User hardware keys", {
    # PUT UNIVERSAL REMAPS FOR HARDWARE KEYS HERE
    # KEYMAP WILL BE ACTIVE IN ALL DESKTOP ENVIRONMENTS/DISTROS
}, when = lambda ctx:
    cnfg.screen_has_focus and
    matchProps(not_lst=remotes_lod)(ctx)
)

if DESKTOP_ENV == 'gnome':

    keymap("User overrides: GNOME", {
        C("Super-Left"):        C("Super-Alt-Left"),            # Move to left workspace
        C("Super-Right"):       C("Super-Alt-Right"),           # Move to left workspace
    }, when = lambda ctx:
        cnfg.screen_has_focus and
        matchProps(not_lst=remotes_lod)(ctx)
    )

    keymap("User overrides: Terms GNOME", {
        C("LC-Left"):           C("Super-Alt-Left"),            # Move to left workspace
        C("LC-Right"):          C("Super-Alt-Right"),           # Move to left workspace
    }, when = lambda ctx:
        cnfg.screen_has_focus and
        matchProps(clas=termStr)(ctx)
    )

###  SLICE_MARK_END: user_apps  ###  EDITS OUTSIDE THESE MARKS WILL BE LOST ON UPGRADE
###################################################################################################

Since the physical Ctrl key is actually Meta/Super/Win/Cmd if we are not in a "terminal" app, we're actually remapping Super+Left/Right for non-terminals, and then there needs to be a second keymap to remap LEFT_CTRL (LC) and Left/Right when in a terminal app.

I can't say right now if any of this will conflict with anything. I'm spending most of my time in Plasma now, so you'll have to test this out and see how it goes.

After you make your edits just save the config file and then restart Toshy from the tray icon menu (with the "Services" item) or with the terminal command toshy-services-restart. If you run into a problem or Toshy doesn't seem to restart properly (watch for the tray icon changing colors every few seconds in a loop, or see if the status is changing in the menu) use toshy-config-verbose-start in the terminal to see the debugging info, in case you made a typo.

If you need to use the debugging command, once you're sure any issue is fixed you can just use the "(Re)Start Services" menu item again. It will automatically stop the verbose process.

I'm expecting this to work out if I understood which physical keys you want to use, and got the remap correct. Let me know how it goes.

denppa commented 1 month ago

This does work, and matches the vanilla MacOS Settings. As with you, I am not sure of any conflicts.

General rant, Gnome removed the tray icon in general, and instead replaced with a different API. I am not saying you should spend your time implementing it, the cli works good enough. But it is just one more thing dissuading me from Gnome if it wasn't for their "market share".

RedBearAK commented 1 month ago

General rant, Gnome removed the tray icon in general, and instead replaced with a different API. I am not saying you should spend your time implementing it, the cli works good enough. But it is just one more thing dissuading me from Gnome if it wasn't for their "market share".

I have never understood why anyone even compares the tray icons to the "background apps" nonsense that the GNOME devs came up with (it still isn't finished, as far as I know). They really don't serve the same purpose. Oh, unless you're talking about the API like Caffeine uses, where it can be part of the status area (the hardware stuff).

The normal tray icons can always be brought back with the AppIndicator & KStatusNotifier extension, as noted in the README. I believe the extension is maintained for Ubuntu, so it's usually working.

But constantly breaking GNOME extensions has caused me to move to Plasma 6, after updating from F39 to F40. I waited for the 6.1 update, and now I'm free of GNOME. With a KWin script for app grouping, and a script that fixes some task switcher settings and shortcuts, it's actually a better Mac-like experience for me than GNOME ever was. Those things will get set up by the Toshy installer if you use the --fancy-pants installer option and you're in Plasma.

This does work, and matches the vanilla MacOS Settings. As with you, I am not sure of any conflicts.

Good to hear. Enjoy. 👍🏽