Skip to content

Instantly share code, notes, and snippets.

@ymkim92
Last active April 30, 2023 01:32
Show Gist options
  • Save ymkim92/87760e8002f7e4113a5b0dd89abc6b10 to your computer and use it in GitHub Desktop.
Save ymkim92/87760e8002f7e4113a5b0dd89abc6b10 to your computer and use it in GitHub Desktop.
# screen on and off by command in ubunu

How to detect if it uses x11 or wayland by command

If it uses the wayland, WAYLAND_DISPLAY has a wayland name.

$ echo $WAYLAND_DISPLAY
wayland-0

Otherwise, it will be null.

https://docs.fedoraproject.org/en-US/fedora/latest/system-administrators-guide/Wayland/#:~:text=If%20the%20window%20is%20running,it%20will%20say%20%E2%80%9CMetaWindowX11%E2%80%9D.

screen on and off in X11

To turn on the screen, use this command:

xset dpms force on

To turn off the screen, use this command:

xset dpms force off

[note] If you have multiple monitors and want to control monitor by monitor, use xrandr command. See this for more detail: https://adamosk.com/turn-off-monitor-using-command-line/

screen on and off in wayland

xset command doesn't work in wayland:

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

switch to X11 and use xset

Set WaylandEnable=false in the file of /etc/gdm3/custom.conf. Then logout and login.

https://linuxconfig.org/how-to-enable-disable-wayland-on-ubuntu-22-04-desktop#:~:text=Wayland%20is%20a%20communication%20protocol,to%20Xorg%20display%20server%20instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment