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?

Archisman Panigrahi
  • 25,210
  • 17
  • 90
  • 185
  • i would do `sudo systemctl restart lightdm`. – Rishon_JR May 06 '23 at 06:19
  • @Rishon_JR (Have you tried using that command? :) ) I want to just turn off the display of my laptop, and not log out of everything. Also Kubuntu does not use lightdm. – Archisman Panigrahi May 06 '23 at 06:24
  • Okay, just a small confusion . You can do `sudo systemctl restart sddm`. Try this [answer](https://askubuntu.com/questions/1792/how-can-i-suspend-hibernate-from-command-line) if you want your computer to go to sleep. – Rishon_JR May 06 '23 at 06:30
  • I want the display to turn off while the laptop continues working. Restarting sddm will close all the running programs and log me out of the session. – Archisman Panigrahi May 06 '23 at 06:34
  • maybe with package `swayidle` ? – nobody May 06 '23 at 08:24
  • Not an answer, but, might save your time ... Your display is obviously not `:0.0` ... You can check with `echo "$DISPLAY"`. – Raffa May 06 '23 at 09:04
  • @Raffa Thanks - The display turned out to be `:1`. Now there is a new error. I have edited the question. – Archisman Panigrahi May 06 '23 at 14:29
  • Wayland doesn't seem to be able to handle external power management requests/commands ... If `xset` is ever going to work for you on Wayland, it would be without the power management option ... So, try just `xset s off` – Raffa May 06 '23 at 14:54
  • I apologize for the mistake ... I meant `xset s on` or `xset s blank` ... it's the screen saver mode ... should be blank screen by default ... Then, activate it with `sleep 2 && xset s activate` ... The `sleep` call is necessary before the command. – Raffa May 06 '23 at 15:18
  • @Raffa `xset s blank && sleep 2 && xset s activate` seems to do nothing. – Archisman Panigrahi May 06 '23 at 15:46
  • Then, I guess you’d need to rely on the power management of the KDE desktop like noted by @meuh below … I don’t use KDE but AFAIK Wayland power management commands don’t work as expected due to the way it is designed/restricted as opposed to the full native power management capabilities of Xorg or at least not as accessible. – Raffa May 06 '23 at 16:24

1 Answers1

2

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,141
  • 13
  • 22
  • +1 It does turn off the monitor. Is there any command to turn it on? Replacing the same command with `Turn On Screen` did not work. Pressing anything on the keyboard/mouse turns on the monitor, but when they are detached in my touch screen tablet, I cannot find any way to find the display on after this. – Archisman Panigrahi May 06 '23 at 21:46
  • If there is no "turn on screen" you should probably accept this question and start a new question for that, as it probably needs a completely different mechanism. – meuh May 07 '23 at 07:08
  • @ArchismanPanigrahi That commands apparently uses shortcuts defined in `systemsettings -> Shortcuts -> Global Shortcuts -> Power Management` If a shortcut isn’t there then you need to define/add it first if possible before you can use it … See https://phabricator.kde.org/D22261 – Raffa May 07 '23 at 08:40