Search code examples
archlinuxwindow-managersi3

How to check whether any window is open in i3


How could I find out whether any window is opened in i3 or not? Like, check if any workspace contains any window.


Solution

  • You can check if any 'visible' window is open in i3 by using xdotool: You can install xdotool with sudo pacman -S xdotool

    WINDOWS=$(xdotool search --all --onlyvisible --desktop $(xprop -notype -root _NET_CURRENT_DESKTOP | cut -c 24-) "" 2>/dev/null)
    NUM=$(echo "$WINDOWS" | wc -l)
    if [ $NUM -eq 0 ]; then
        echo "No windows open."
    fi