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

How to count number of windows of certain type?

asked 2015-06-03 17:09:55 +0000

tenspd137 gravatar image

Hi all,

I often find myself using python scripts that generate a lot of graphs. I'd like to create a script that will count the number of graphs in a workspace and then line them up in a grid - ie if 6 are plotted, arange them all in a 2x3 grid. I know I am going to have to script this - no problem, but the first thing I need to figure out is how to programtically cycle through all the windows in a workspace. I know how to use xprop to get the window type, but I can't seem to find something like (pseudo code):

for window in workspce; goto window; ...

of course, after goto window, you can get the type and keep track of things, etc. Just need to get started. Any help is appreciated!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-06-03 17:41:09 +0000

Michael Rose gravatar image

wmctrl -l can list the windows starting with the window id which can be fed to xprop. There are also convenient libraries to use to interact with your shell easier

https://pypi.python.org/pypi/shell/1.0.1 https://amoffat.github.io/sh/

That said you might want something more i3 oriented as you it sounds like you want the windows in your workspace not all that match a criteria as you may someday have more than one workspace with matching windows.

In theory you could get all you need from i3-msg -t get_tree and use jq to process the resulting json but since you mentioned python you probably want

https://github.com/acrisci/i3ipc-python

edit flag offensive delete link more

Comments

Thanks! I will try that. Of course, this is a "Gee-job" at work, so it might take me a little time to figure it all out, but you pointed me to some useful stuff, so I am going to give you credit for the answer :) Thanks!

tenspd137 gravatar imagetenspd137 ( 2015-06-03 19:42:43 +0000 )edit

Question Tools

1 follower

Stats

Asked: 2015-06-03 17:09:55 +0000

Seen: 102 times

Last updated: Jun 03