You are not logged in.
I'm trying to write a script that will count how many open windows a specific application has, for example palemoon. I already tried
ps -aux | grep palemoon
While I have two fresh palemoon windows (only one tab per window), the above command shows only one instance of /usr/bin/palemoon running:
ps -aux | grep palemoon
george 31403 13.6 12.6 573188 260000 ? Sl 18:27 2:56 /usr/bin/palemoon
george 32335 0.0 0.1 4900 2188 pts/3 S+ 18:49 0:00 grep palemoon <--- this line is ignored
How can I get as a result the real number of open windows for palemoon (which in the above example is obviously 2)?
Last edited by helix (2015-06-12 17:02:38)
Offline
xwininfo -root -tree should provide more than enough information
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
Thank you ewaller, exactly what I wanted! This did the trick:
xwininfo -root -tree | grep moon | grep '^ ' | wc -l
For some reason the program name in the results of xwininfo is "Pale Moon" or "Pale moon", so grepping palemoon instead of moon would fail
Offline
It sure does provide a lot of info, but parsing it seems tricky.
I don't even know how to count how many tabs one instance of firefox has open.
@OP
Why do you need this information?
Edit: Does
xwininfo -root -tree | grep -ci moon
work too?
Last edited by karol (2015-06-12 17:06:23)
Offline
No, it gives result 16
Offline