You can use i3-msg -t get_tree
to dump the JSON whole tree of your existing workspaces / windows. The amount of data is quite big so you'll need to parse it to extract the data you want.
Either implement your own or use a binding that simplifies the job, e.g in Python, github.com/ziberna/i3-py.
Example:
import i3
# get a list of workspaces
for workspace in i3.get_workspaces():
# get the workspace tree data
workspace_tree = i3.filter(num=workspace.get('num'))
# get a list of existing leaf windows in that workspace
for window in i3.filter(workspace_tree, nodes=[]):
# do something useful here
print 'workspace %d' % workspace.get('num'), 'window:', window.get('name')
This would output such thing:
workspace 1 window: duplicity-backup - Runs duplicity for backups to FTP
workspace 1 window: man duplicity
workspace 3 window: How to find out which windows are currently visible? or which workspace they belong to - i3 FAQ - Mozilla Firefox
workspace 3 window: ipython
workspace 9 window: Quassel IRC
workspace 10 window: newsbeuter
workspace 10 window: ncmpcpp
workspace 10 window: htop
The window
dictionary in the python snippet contains useful stuff like that:
fullscreen_mode, orientation, focus, urgent, last_split_layout, floating, border, id, current_border_width, layout, percent, workspace_layout, window, nodes, type, swallows, focused, scratchpad_state, rect, window_rect, name, geometry, floating_nodes