The i3 FAQ has migrated to All content here is read-only.
Ask Your Question

Focus next window

asked 2012-08-27 11:46:56 +0000

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.

edit retag flag offensive close merge delete


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 ( 2012-08-27 11:53:49 +0000 )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 ( 2012-08-27 15:50:38 +0000 )edit

Need karma of 50 to accept it :-(

lzap gravatar imagelzap ( 2012-08-27 21:45:27 +0000 )edit

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

Michael gravatar imageMichael ( 2012-08-28 08:15:20 +0000 )edit

5 answers

Sort by ยป oldest newest most voted

answered 2013-10-17 20:47:11 +0000

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.

edit flag offensive delete link more

answered 2012-08-27 21:45:08 +0000

lzap gravatar image

I was wrong, this does cycle:

bindsym Mod1+Tab focus right
bindsym Mod1+Shift+Tab focus left
edit flag offensive delete link more


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 ( 2015-05-19 11:31:52 +0000 )edit

answered 2013-10-17 18:40:46 +0000

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

edit flag offensive delete link more

answered 2013-01-30 00:13:21 +0000

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]

edit flag offensive delete link more


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

Michael gravatar imageMichael ( 2013-01-31 10:28:47 +0000 )edit

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

AsaAyers gravatar imageAsaAyers ( 2015-04-18 15:09:28 +0000 )edit

answered 2012-12-10 16:31:14 +0000

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.

edit flag offensive delete link more

Question Tools


Asked: 2012-08-27 11:46:56 +0000

Seen: 3,073 times

Last updated: Oct 17 '13