Page 1 of 1

[Sovled] How to disable screen on laptop when using it via ssh?

Posted: 2020/09/13 19:41:06
by m0t0m
I am using my laptop as an CentOS 8.2 server. I would like to disable the display as I am only accessing it via ssh.
The laptop is a Dell Inspiron 1545 running CentOS Linux release 8.2.2004 (Core)

So far I have tried:
  • xrandr --output CRT1 --off
Any ideas?

Re: How to disable screen on laptop when using it via ssh?

Posted: 2020/09/13 20:20:45
by KernelOops
I had to do something similar, disable the laptop display because I was using an external monitor.

The way to do that, I had to ssh to the laptop as the user that was logged in as a GUI user (thus had permission to use xrandr) and discover the name of the laptop display:

Code: Select all

ssh user@laptop
$ DISPLAY=:0
$ export DISPLAY
$ xrandr | grep connected
eDP-1 connected
HDMI-1 connected
Now I know that eDP-1 is the laptop display and HDMI-1 is the external monitor. Now I can disable the laptop display by name. Reconnect and run:

Code: Select all

ssh user@laptop
$ DISPLAY=:0
$ export DISPLAY
$ xrandr --output eDP-1 --off
That works for me over ssh, but it does not work if I try that as a cronjob. I believe the correct way would be some kind of kernel argument in GRUB2.

Re: How to disable screen on laptop when using it via ssh?

Posted: 2020/09/14 11:19:42
by m0t0m
I don't have Xwindow installed as I only use the shell.

When I use your commands I get

Code: Select all

[user@localhost ~]$ DISPLAY=:0
[user@localhost ~]$ export DISPLAY
[user@localhost ~]$ xrandr | grep connected
Can't open display :0

Re: How to disable screen on laptop when using it via ssh?

Posted: 2020/09/25 16:59:15
by m0t0m
OK it works.

I installed added a GUI to my CentOS install and then your commands worked as you described.

Code: Select all

$ DISPLAY=:0
$ export DISPLAY
$ xrander | grep connected
LVDS-1 connected primary (normal left inverted right x axis y axis)
VGA-1 disconnected (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)
$ xrandr --output LVDS-1 --off
However I need the GUI to be able to run the commands. So I made CentOS boot into GUI mode, and now the screen turns off on its own when I do use it for a while.