herhuf
herhuf

Reputation: 517

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.

Upvotes: 1

Views: 1714

Answers (2)

Jebby
Jebby

Reputation: 1955

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

Upvotes: 2

red
red

Reputation: 26

maybe try i3-save-tree. You must install perl-anyevent-i3 and perl-json-xs first.

https://i3wm.org/docs/layout-saving.html

Example:

$ i3-save-tree --workspace 10
// vim:ts=4:sw=4:et
{
    "border": "pixel",
    "current_border_width": 1,
    "floating": "auto_off",
    "geometry": {
       "height": 720,
       "width": 1366,
       "x": 0,
       "y": 0
    },
    "name": "Waterfox Start Page - Waterfox",
    "percent": 1,
    "swallows": [
       {
       // "class": "^Waterfox$",
       // "instance": "^Navigator$",
       // "title": "^Waterfox\\ Start\\ Page\\ \\-\\ Waterfox$",
       // "transient_for": "^$",
       // "window_role": "^browser$"
       }
    ],
    "type": "con"
}

Upvotes: 0

Related Questions