sometiems it would be convinent to enable that function. but how?
This is maybe not the most elegant way but just a first quick-and-dirty Python/Bash implementation. I have written a python script that extracts all window id's from the layout tree and prints the one after the currently focused window. The script's output is then used by a bash script to go to this window via i3-msg (could be done in the python script as well I think...) You can then configure your i3 such that you can walk over all windows (with exceptions, see "Drawbacks" below) using e.g. Alt+Tab.
Here is the code for id_list.py:
import json import subprocess """ Execute the given command and return the output as a list of lines """ def command_output(cmd): output =  if (cmd): p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, \ stderr=subprocess.STDOUT) for line in p.stdout.readlines(): output.append(line.rstrip()) return output def output_to_dict(output_list): output_string = "" for line in output_list: output_string += line return json.loads(output_string) def find_windows(tree_dict, window_list): if (tree_dict.has_key("nodes") and len(tree_dict["nodes"]) > 0): for node in tree_dict["nodes"]: find_windows(node, window_list) else: if (tree_dict["layout"] != "dockarea" and not tree_dict["name"].startswith("i3bar for output") and not tree_dict["window"] == None): window_list.append(tree_dict) return window_list def main(): output = command_output("i3-msg -t get_tree") tree = output_to_dict(output) window_list = find_windows(tree, ) next_index = -1 for i in range(len(window_list)): if (window_list[i]["focused"] == True): next_index = i+1 break # next_index = len(window_list) # for i in range(len(window_list)-1, -1, -1): # if (window_list[i]["focused"] == True): # next_index = i-1 # break next_id = 0; if next_index == -1 or next_index == len(window_list): next_id = window_list["window"] else: next_id = window_list[next_index]["window"] print next_id main()
and the bash script tab_windows.sh:
#!/bin/bash id=`python ~/.i3/id_list.py` i3-msg [id="$id"] focus > /dev/null
Suppose these scripts lay in ~/.i3/ insert the following line into your i3 config:
bindsym Mod1+Tab exec ~/.i3/tab_windows.sh
It has been asked for multiple times, but won't be implemented.
Maybe it will be more easily findable if quoted here:
- Cycling through windows in focus order (like alt-tab) is something we don’t want to implement: The order in which alt+tab switches through windows is not easily predictable (due to our internal tree layout), thus either not doing what you want or making a separate visual element necessary (like a window list).
- Having such a visual element as discussed in 1 would need hand-eye coordination: you press a key (hand), then look at the screen, figure out what you want, then press another key.
- Direction focus is quicker. Instead of having one shortcut to go through all windows, you have 4. Maybe slowpoke’s window switching script (ask him on IRC) is what you are looking for.
If it’s not, maybe you can build your idea with the IPC interface. It’s not going to be in core i3, though.
You can use mod+arrows to change focus. What do you mean "alt+tab"? Switching focus inside virtual desktop? Switching focus between all of windows on all of desktops? Changing position?
Closest you can relatively easily get is to use VIM-like marks feature. One may recommend to configure keyboard bindings to mark windows with single letters (see the userguide and
man i3-input). With those markings, many things are possible, but I think "Alt+Tab" is not one of them.
I assume you want to cycle between windows in the order they last had focus, instead of their orientation on the screen. As far as I know there is no such functionality out of the box in i3wm. At least I didn't find any way to do it when I switched to i3wm. You get used to switching using orientation after a while though.
Asked: 2013-05-09 08:57:37 +0000
Seen: 7,252 times
Last updated: Nov 13 '13