1

I am using Kubuntu 23.04 with Wayland.

I found this answer, which works in two other computers running (Kubuntu 22.04 and Ubuntu MATE 22.04) X.Org, but this does not seem to work in my Wayland computer.

$ echo "$DISPLAY"
:1
$xset -display :1 dpms force off

server does not have extension for dpms option xset: unknown option force

How to turn display on and off using the command line, when the display manager is Wayland?

2 Answers2

4

For days, weeks, I scoured the Internet for a solution on how to turn off monitors in Wayland via the command line.

Nothing was found. It was a very hard problem. Many people asking for it, no readily-found solutions.

So I created one!

turn-off-monitors is a nearly-universal Linux command line utility to turn off your computer’s monitors from the CLI.

Tested in:

  • Arch Linux 2024-08-12 (xorg (gnome + kde + xfce + cinnamon + gnome classic + mate), gnome-wayland, gnome-classic-wayland, kde-wayland)
  • RHEL 8.8 (gnome-wayland)
  • Ubuntu 22.04 (xorg (gnome + kde), gnome-wayland, kde-wayland)
  • EndeavourOS (xorg (kde), kde-wayland)

In fact, it’s the first published code to turn off monitors on Gnome Wayland that is cross-distro.

3

I don't use kde but I noted this page talking about "kde connect" (which seems to be a way to type commands to a kde desktop from a phone). It suggests:

Turn off screen:

sleep 0.1 && qdbus org.kde.kglobalaccel /component/org_kde_powerdevil invokeShortcut "Turn Off Screen"

I had also noted from somewhere, the probable equivalent:

dbus-send --session --dest=org.kde.kglobalaccel \
  /component/org_kde_powerdevil \
  org.kde.kglobalaccel.Component.invokeShortcut string:'Turn Off Screen'

If kde shares some protocol with wlroots-based compositors, you can try wlr-randr.

meuh
  • 3,444