The i3 FAQ has migrated to https://github.com/i3/i3/discussions. All content here is read-only.
Ask Your Question
0

Focus next window

asked Aug 27 '12

lzap gravatar image

Hello, it seems Alt+Tab combination is not used and I wonder if I could set something like "focus next". I would like to cycle through all my windows from both screens, something similar than in traditional workspaces. I tried to setup "focus right" or "left", but when it reaches the last window, it stops.

Comments

Hmmm I was wrong, my configuration was not loaded properly. Focus right or left DOES cycle. So this is what I actually want :-)

lzap gravatar imagelzap (Aug 27 '12)edit

Can you please just answer your own question with an actual answer (and then accept it)? Search engines actually parse the number of answers.

Michael gravatar imageMichael (Aug 27 '12)edit

Need karma of 50 to accept it :-(

lzap gravatar imagelzap (Aug 27 '12)edit

I think waiting for a week helps, at least I can accept it in a week.

Michael gravatar imageMichael (Aug 28 '12)edit

5 answers

Sort by » oldest newest most voted
2

answered Oct 17 '13

cee gravatar image

I am using simpleswitcher for some time now.
That means it just waits until I (accidentially) hit Alt+Tab. I try to memorize where my open programs are, so that I don't have to cycle through them. But it's still handy from time to time.

I have got the tip from the following forum post.

0

answered Aug 27 '12

lzap gravatar image

I was wrong, this does cycle:

bindsym Mod1+Tab focus right
bindsym Mod1+Shift+Tab focus left

Comments

This is simple and does what is asked for. Sadly, I can't upvote it yet, as I don't have 10 reputation.

voyd gravatar imagevoyd (May 19 '15)edit
0

answered Oct 17 '13

Thank you! I use the "stacked" layout almost entirely (vertical tabs), and have made this small adjustment to the above suggestion to cycle through them, and it works beautifully

bindsym Mod1+Tab focus up
bindsym Mod1+Shift+Tab focus down

Now one of my most engrained lifelong habits from 'other' window managers is serving me once again in i3. Love it! =D -ViktorNova

0

answered Jan 30 '13

mats gravatar image

Here's a Python function that implements a generic focus next command using i3-py:

def focus_next():
    num = i3.filter(i3.get_workspaces(), focused=True)[0]['num']
    ws_nodes = i3.filter(num=num)[0]['nodes']
    curr = i3.filter(ws_nodes, focused=True)[0]

    ids = [win['id'] for win in i3.filter(ws_nodes, nodes=[])]

    next_idx = (ids.index(curr['id']) + 1) % len(ids)
    next_id = ids[next_idx]

    i3.focus(con_id=next_id)

Comments

I suppose this does not work for floating windows since you access ['nodes'] directly.

Michael gravatar imageMichael (Jan 31 '13)edit

`ws_nodes = ws_nodes + i3.filter(num=num)[0]['floating_nodes']` Adding that will capture the floating nodes too.

AsaAyers gravatar imageAsaAyers (Apr 18 '15)edit
0

answered Dec 10 '12

tdavis gravatar image

The problem with the selected answer is that "right" and "left" only work properly on a horizontal layout. With these bindings and a vertical layout, nothing happens. There doesn't appear to be generic "focus next" / "focus prev" so my instinct is to write an i3-py script to first try "right", see if the current window changed and, if not, try "down" instead.

Question Tools

Stats

Asked: Aug 27 '12

Seen: 3,073 times

Last updated: Oct 17 '13