Get the count of currently active windows in the current Activity and Virtual Desktop?

282 Views Asked by At

There is a bug in KDE Activities where windows do not get focused and this requires to press Alt+Tab to switch to the last active window.

I want to count the number of the windows to press only when there is some, I tried

xdotool search --onlyvisible --desktop 2 --name ''

but it gets all the desktops in all the activities, I want to get the desktops in the current activity only

1

There are 1 best solutions below

0
Mahyar Iranibazaz On

The current desktop number can be found using

xdotool get_desktop

You can mix this with your command to find the windows in the current active desktop

xdotool search --desktop $(xdotool get_desktop) --class ''

Then to get the count by piping the result into wc tool as lines

xdotool search --desktop $(xdotool get_desktop) --class '' | wc -l