3

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?

  • Which window manager are you using? Metacity (the Gnome 2 default)? Mutter (the Gnome 3 default)? Something else? – Gilles Aug 25 '16 at 23:05
  • The default window manager, I think. Whatever that is. I think I'm using the very latest GNOME, not the one from last decade. – Jonathan Aug 25 '16 at 23:39
2

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

  1. 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.
  2. 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.

  3. 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:

  1. install xdotool on your system, it should be in your repo :)
  2. git clone https://gitlab.com/gabrieldevillers/xdotool-i3ization
  3. go to Gnome3 > Keyboard > Shortcuts > Personal shortcuts and add 4 entries with commands respectively /path/to/select.sh *direction* where *direction* is respectively up, down, left or right

Problems of the script:

  1. It's slow (but usable: try it)
  2. 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:

  1. 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!)
  2. Filter this list to get the windows at the correct location (this part of my script has a lot of room for improvement)
  3. Take the one that is the closest to you (here again you can improve my script)
  • This is awesome. I didn't know about xdotools before, so that's great. The script doesn't quite work for me, gives X Error of failed request: BadWindow (invalid Window parameter), but it gives me more than I need to go on to make something like this myself. You can make the script a little faster probably by using the --shell option of xdotool with eval. Also it turns out the shell extension is probably this one: extensions.gnome.org/extension/39/put-windows – Jonathan Sep 3 '16 at 15:03
  • Great, you found the extension :) I edited my answer to add it. Thanks, I will implement your suggestion next time I'll play with xdotool. – Gabriel Devillers Sep 3 '16 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.