1

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

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
herhuf
  • 497
  • 3
  • 17

2 Answers2

2

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
Jebby
  • 1,845
  • 1
  • 12
  • 25
0

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"
}
red
  • 26
  • 3