16

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:

1
  • I know at least on Ubuntu with GNOME you can use the <kbd>Super</kbd>+<kdb>D</kbd> to minimize all windows. – Shane Bishop Jan 9 at 19:23
1

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())"
0

TL;DR You can still do that

While xdotool uses X11 APIs and therefore will not work on Wayland, wmctrl interacts with the desktop environment itself. Therefore, while its commands requiring X11 APIs will not work, you can still use many wmctrl commands in a Wayland session, -k on included.

Tested on Arch Linux using GNOME Shell 3.30.2 and wmctrl 1.07.

2
  • 7
    It only works with X windows, wayland native applications are not supported (listed). – Dyorgio Aug 5 '19 at 0:24
  • Wayland is just protocol that simplifies the graphics stack. Many "applications" are in process of being ported from X to Wayland. May be this wmctrl is connected to XWayland. I am not sure where that function call take place but it did work for me. – kasa Feb 10 at 5:13
0

I will describe a workaround that works for me on my playground Manjaro machine with GNOME3/Wayland. Keep in mind that the process may slightly differ on other distributions.

It is not as perfect as I imagined, but it works.

ydotool

In this method, I will use ydotool. From README.md:

ydotool works differently from xdotool. xdotool sends X events directly to X server, while ydotool uses the uinput framework of Linux kernel to emulate an input device.

  1. Install it accordingly to your distribution - AUR, Ubuntu, Debian, etc...
  2. You may need to properly set access rights for /dev/uinput and allow the user to access this device. In this case, add a user to the users group and create udev rules file:

Add yourself to users group:

usermod -a -G users $USER

Create /etc/udev/rules.d/80-uinput.rules file with following content:

KERNEL=="uinput", GROUP="users", MODE="0660", OPTIONS+="static_node=uinput"
  1. You need to start /usr/bin/ydotoold socket listener. For testing purposes start in manually, but you probably want to autostart this on login.

  2. GNOME 3 allows you to set a keyboard shortcut to "Hide all normal windows". Go to the gnome-control-center, Keyboard Shortcuts, Navigation, Hide all normal windows. Set this shortcut, for example, to Super + D.

  3. Now, if everything works as expected, you should be able to minimise all GNOME/Wayland windows with the following command:

ydotool key Super+D

wtype

Another method could be to use wtype. It seems to use a different approach and provides keyboard events directly to the compositor. The problem is I was not able to make this work with GNOME's default compositor mutter. It may be related to the limitations of XWayland but I'm not sure about this. All I get is the error:

Compositor does not support the virtual keyboard protocol

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.