Score:1

How to turn off laptop monitor using command line in Wayland?

us flag

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?

Rishon JR avatar
pl flag
i would do `sudo systemctl restart lightdm`.
us flag
@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.
Rishon JR avatar
pl flag
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.
us flag
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.
nobody avatar
gh flag
maybe with package `swayidle` ?
Raffa avatar
jp flag
Not an answer, but, might save your time ... Your display is obviously not `:0.0` ... You can check with `echo "$DISPLAY"`.
us flag
@Raffa Thanks - The display turned out to be `:1`. Now there is a new error. I have edited the question.
Raffa avatar
jp flag
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 avatar
jp flag
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.
us flag
@Raffa `xset s blank && sleep 2 && xset s activate` seems to do nothing.
Raffa avatar
jp flag
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.
Score:2
cn flag

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.

us flag
+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.
meuh avatar
cn flag
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.
Raffa avatar
jp flag
@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
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.