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
Graphics:
  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

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..

#!/bin/sh
intern=LVDS1
extern=VGA1
if xrandr | grep "$extern disconnected"; then
xrandr --output "$extern" --off --output "$intern" --auto
else
xrandr --output "$intern" --off --output "$extern" --auto
fi

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

https://wiki.archlinux.org/title/Xrandr

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

2 Likes

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:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.