mzur / gnome-shell-wsmatrix

GNOME shell extension to arrange workspaces in a two-dimensional grid with workspace thumbnails
GNU General Public License v3.0
464 stars 59 forks source link

Add missing keybindings to system settings #150

Closed ShrirajHegde closed 3 years ago

ShrirajHegde commented 3 years ago

Switching left-right doesn't work in Fedora, but a comment on https://extensions.gnome.org/extension/1485/workspace-matrix/ has a method to fix this problem.

" by lbecea Overall it is a nice and useful extension. Unfortunately for Pop!_os 20.10 switching left/right didn't work

Fortunately, I found this two commands to fix it:

gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-right "[\"<Ctrl><Super>Right\"]"

gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-left "[\"<Ctrl><Super>Left\"]"

"

Can you make these keybinding settings automatically during installation/mention this in README?

mzur commented 3 years ago

We have a wiki article about custom shortcuts linked in the readme. What keyboard shortcut have you tried? The defaults are Ctrl+Alt+🠖 (right) and Ctrl+Alt+🠔 (left).

ShrirajHegde commented 3 years ago

ctrl + super + 🠖 and ctrl + super + 🠔

I think fedora uses this keybinding...(for up and down ad default)

ShrirajHegde commented 3 years ago

and move window to [left] or [right] works, but [up] or [down] doesn't

ShrirajHegde commented 3 years ago

ok, shift + super + 🠗/🠕 works for moving and ctrl + shift + alt + 🠔/🠖 works for moving

totally scattered for some reason, probably because super based shortcuts are set by fedora

mzur commented 3 years ago

These are the default keybindings in my Fedora 34 beta VM:

[liveuser@localhost-live ~]$ gsettings get org.gnome.desktop.wm.keybindings switch-to-workspace-right
['<Super>Page_Down', '<Super><Alt>Right', '<Control><Alt>Right']
[liveuser@localhost-live ~]$ gsettings get org.gnome.desktop.wm.keybindings switch-to-workspace-left
['<Super>Page_Up', '<Super><Alt>Left', '<Control><Alt>Left']
[liveuser@localhost-live ~]$ gsettings get org.gnome.desktop.wm.keybindings switch-to-workspace-up
['<Control><Alt>Up']
[liveuser@localhost-live ~]$ gsettings get org.gnome.desktop.wm.keybindings switch-to-workspace-down
['<Control><Alt>Down']

So it's either ctrl+alt or super+alt but not ctrl+super.

ShrirajHegde commented 3 years ago

ok, then I might have overwritten the shortcuts while syncing extensions with https://extensions.gnome.org/extension/1486/extensions-sync/

ShrirajHegde commented 3 years ago

These are the default keybindings in my Fedora 34 beta VM:

[liveuser@localhost-live ~]$ gsettings get org.gnome.desktop.wm.keybindings switch-to-workspace-right
['<Super>Page_Down', '<Super><Alt>Right', '<Control><Alt>Right']
[liveuser@localhost-live ~]$ gsettings get org.gnome.desktop.wm.keybindings switch-to-workspace-left
['<Super>Page_Up', '<Super><Alt>Left', '<Control><Alt>Left']
[liveuser@localhost-live ~]$ gsettings get org.gnome.desktop.wm.keybindings switch-to-workspace-up
['<Control><Alt>Up']
[liveuser@localhost-live ~]$ gsettings get org.gnome.desktop.wm.keybindings switch-to-workspace-down
['<Control><Alt>Down']

So it's either ctrl+alt or super+alt but not ctrl+super.

is it practical to provide a shortcut picker in the extension?

ebeem commented 3 years ago

@ShrirajHegde That will be a good idea I think, I know it's not very hard to implement it if we will ask users to enter their keybindings in text format (like '<Control><Alt>Down'), but it doesn't seem easy to kind of listen to the shortcut while assigning (even gnome keybindings app doesn't have this feature).

Anyways, I think it's a good idea to have a keybindings section in the preferences, what do you think @mzur?

mzur commented 3 years ago

Sorry but I have a different view. In my opinion we don't gain much by offering keybinding configuration in the settings of this extension. If it's in the text format, why don't just do it in the console? Also, there are a lot of keybindings we would have to support there.

In my view, the place to offer such a thing would be the Keyboard Shortcuts menu in the system settings. On my system (Ubuntu 20.04) this menu does support a "listen to keypress" feature to assign new keybindings. If we could manage to add the missing entries for the "switch left/right" etc. keybindings there, this would have my full support.

ShrirajHegde commented 3 years ago

yeah, switch to left-right and move to left/right are missing, rest can be set in gnome-control-center

another idea is, checking what keybindings are set for 🠗/🠕 and automatically matching the same for 🠔/🠖 (in both move window or switch to)

the second one would be seamless

mzur commented 3 years ago

I'll opt for adding the missing shortcuts to the system settings for now. I don't want to change the defaults with this extension.

Anyone who wants to contribute is welcome to try to implement this. For GNOME <40 the "left" and "right" keybindings should be added and for GNOME 40 "up" and "down" should be added to the Keyboard Shortcuts menu of the system settings..

ebeem commented 3 years ago

Actually, with the current implementation and progress, the key-handling will be stolen once the switcher shows up (similar to switching windows/apps/input in gnome). So far, I only found one function which will force us to handle keys there and that's what I am going for right now. This will require extension configuration as they are hard coded now. You can actually check that once the switcher appears in input/windows/app switcher, it will steal key-handling and you won't be able to switch workspaces for example with ctrl+alt+right.

      // handling key presses while the switcher popup is displayed
      _keyPressHandler(keysym, action) {
         // default keybindings with arrows
         if (action == Meta.KeyBindingAction.WORKSPACE_LEFT || keysym == Clutter.KEY_Left)
            this.select(this.getTargetWorkspaceIndexByDirection(Meta.MotionDirection.LEFT));
         else if (action == Meta.KeyBindingAction.WORKSPACE_RIGHT || keysym == Clutter.KEY_Right)
            this.select(this.getTargetWorkspaceIndexByDirection(Meta.MotionDirection.RIGHT));
         else if (action == Meta.KeyBindingAction.WORKSPACE_UP || keysym == Clutter.KEY_Up)
            this.select(this.getTargetWorkspaceIndexByDirection(Meta.MotionDirection.UP));
         else if (action == Meta.KeyBindingAction.WORKSPACE_DOWN || keysym == Clutter.KEY_Down)
            this.select(this.getTargetWorkspaceIndexByDirection(Meta.MotionDirection.DOWN));
         // todo: maybe add more keybindings from preferences here, and make both arrows and keypads default configs but not hardcoded
         else
            return Clutter.EVENT_PROPAGATE;

         return Clutter.EVENT_STOP;
      }

What do you think @mzur? Will this be good substitute to the current way we implement workspace switcher popup? I think switching windows/apps/input is behaving exactly the same way we desire.

this has potential to solve all of #145 #140 #126 #88 #12

mzur commented 3 years ago

@ebeem I can't say before I had a look at the code. Just do what you think is best and we can continue the discussion in your PR. It's not directly related to this issue, I think. Just a quick comment:

You can actually check that once the switcher appears in input/windows/app switcher, it will steal key-handling and you won't be able to switch workspaces for example with ctrl+alt+right.

This is already the case in older GNOME versions (e.g. 3.36).

ebeem commented 3 years ago

I am not handling the keybindings in GNOME 40 anymore, I am getting them from gsettings. So I think for this issue, we just need to have a ready script to assign the default keybindings (Ctrl+Alt+arrows) as @mzur suggested.

ebeem commented 3 years ago

Section added to https://github.com/mzur/gnome-shell-wsmatrix/wiki/Custom-keyboard-shortcuts I second @mzur now with the keybindings managed by another tool, we need a better tool to manage all of GNOME's keybindings rather than building an interface for it in each and every extension. This extension doesn't actually create any additional keybindings (except for the workspace toggle part). All the keybindings used here are built-in GNOME. So I think there's no need to manage them in this extension.

You can see that gsettings will allow you to list/get/set all keybindings, check gsettings list-recursively. dconf-editor can be used to check and modify these keybindings, it's a good interface but I don't like how it handles assigning keybindings (you need to manually provide it as a string, e.g. ['<Control><Shift><Alt>Left'].

Screenshot from 2021-05-17 12-28-07

GNOME Keyboard on the other hand doesn't show all available keybindings. However, its interface is great and it allows you to easily set shortcuts just by pressing them (no need to provide it as a string).

Screenshot from 2021-05-17 12-28-39

Please feel free to reopen this if you still think it's a needed feature, maybe we can discuss it further.