I can't enable a sub-display with a single xrandr command

I want to enable a sub-display only when I use it, so I ran the command xrandr --output HDMI-A-0 --auto, but I had to run it twice to get it to work. Why is that?

Below is information about my graphics device.

$ inxi -G
  Device-1: AMD Raven Ridge [Radeon Vega Series / Radeon Vega Mobile Series] 
  driver: amdgpu v: kernel 
  Display: x11 server: X.Org 1.20.13 driver: amdgpu 
  resolution: 1920x1080~60Hz, 1920x1080~60Hz 
  OpenGL: renderer: AMD Radeon Vega 11 Graphics (RAVEN DRM 3.42.0 
  5.15.0-60-generic LLVM 12.0.0) 
  v: 4.6 Mesa 21.2.6

Are you logged in under Wayland or gnome/xfce? I ask because Wayland doesn't use the Xorg service, which needs to start for xrander to work. That would be why you have to enter it twice the first time. It is starting the service, then you can access it. Maybe adding it to startup applications so you only have to enter the command once.

I use Gnome and Xorg is running.

1 Like

Gday @Hackgets
I was thinking adding --force?
or even --primary then reverse --noprimary, but this may change default settings of screens..
i looked the following link, & in section #3
There is a good BASH script to maybe help..

if xrandr | grep "$extern disconnected"; then
xrandr --output "$extern" --off --output "$intern" --auto
xrandr --output "$intern" --off --output "$extern" --auto

Note: To leave the default monitor enabled when an external monitor is connected, replace the else clause with xrandr --output "$intern" --primary --auto --output "$extern" --right-of "$intern" --auto

Also a wrapper for Xrandr called xrasengan.
& you can use something like this,
$ xrasengan --force -on DisplayPort-0 -off HDMI-0


Thanks @Ocka ! I found that the cause of this problem was that my PC had one HDMI and one DP port and I was using both. Then I decided to use a more primitive workaround.

xrandr --output HDMI-A-0 --auto
sleep 5
xrandr --output HDMI-A-0 --auto


Your Welcome,
Yes sometimes another way can trigger an idea.

I like your " Cheat " workaround :rofl:
" Sleep 5 "
i didn't even think of that, good job.

1 Like