Shell – How to minimise all GNOME/Wayland windows from the command line

gnome-shellgnome3wayland

Before switching to Wayland I would minimise all GNOME Shell windows with the following command:

wmctrl -k on

…but both wmctrl and xdotool are X11-only applications. What CLI command can I use to minimise all windows in a GNOME Shell / Wayland session?

References:

Best Answer

As in my other answer regarding wmctrl, we can use GJS through gdbus in Gnome to do this:

gdbus call \
  --session \
  --dest org.gnome.Shell \
  --object-path /org/gnome/Shell \
  --method org.gnome.Shell.Eval \
  "global.get_window_actors().forEach(w=>w.meta_window.minimize())"
Related Question