I tried xdotool search --name firefox | wc -l
, but it shows wierd numbers like 8,11 or more, when only one windows is opened. Any ideas? Thanks!
Try with the option --onlyvisible. Like this:
xdotool search --onlyvisible --name firefox | wc -l
It worked here. Maybe it could work for you too.