I basically want to keep using GNOME but emulate the i3 WM behavior that allows you to focus windows based on their location, e.g. to focus the window to the right of the current one, to focus the one of the left, etc. I looked into wmutils, which almost works, but it doesn't work with GNOME. Is there another way to do it?
Long answer short: use the extension Put Windows (''Move focus using the keyboard'' says it all)
First you check that it is really not currently possible
- The feature does not seem to be listed in the GnomeShell CheatSheet, neither in Gnome3 > Keyboard. Sadly there does not seem to be an exhaustive list of keyboard shortcuts anywhere.
I went to extensions.gnome.org and searched for an extension that would do what you want but all I found is an extension called 'switcher' that is not what you want. You should search thoroughly there before doing anything else because I did not went through 90 pages of results. Actually there is an extension to do that, it's called ''Put Window'', the OP found it after I wrote this answer, so what is below is kept for information purpose.
You could decide to use Alt-tab and be done with it, that seems to be the Gnome3 way
Then you try to make it possible by yourself
I see 3 ways of doing things:
- Create a Gnome3 extension (but I am not sure that you would have all functions that are needed to implement what you want). I did not try to do that.
- Modify Gnome3 (but that is probably not the answer you are expecting). I did not try to do that.
- Use X11 / Wayland / Mir to do that. I will explain below what I tried to do with X11. Beware, X11 will soon be legacy software ! And it might currently not be possible to do that with Wayland / Mir (but I did not check)
I tried to do that with X11 using xdotool
This solution is not fully working. It's more a hack for fun than anything else
You can try my demo select.sh script. It's a bash script around 200 lines so I do not put it here but I will explain how it work below. To use it:
- install xdotool on your system, it should be in your repo :)
- git clone https://gitlab.com/gabrieldevillers/xdotool-i3ization
- go to Gnome3 > Keyboard > Shortcuts > Personal shortcuts
and add 4 entries with commands respectively
Problems of the script:
- It's slow (but usable: try it)
- windows must not overlap. It's a condition that I used to replace the fact that I had no way to tell if a window is visible to the user (see questions "Computing the visible area of a partly hidden window" and "X: Find out if a window is visible to the user i.e. not covered by others" on this very website). This need is due to the big difference between i3 and Gnome3: with Gnome3 windows can overlap (and they do overlap really often).
Algorithm of the script:
- Get a list of potential windows: they must have a name, be on the same workspace (optional ? but beware there is a bizzare workspace with code "-1"), not be in the list of windows that you excluded (maybe optional, I started with that and kept the possibility), be visible (in the sense of X11, that means not reduced, you know, like in Gnome2!)
- Filter this list to get the windows at the correct location (this part of my script has a lot of room for improvement)
- Take the one that is the closest to you (here again you can improve my script)
As an old I3 user I've been missing this feature. I've failed to find a solution to this problem and so I decided to write a gnome extension to solve it. Instead of using the "xdotool", it uses the internal gnome libs. Hopefully, it will be working in both X11 and Wayland.
As keyboard-driven users, I hope you will also find it helpful.