Linux – xrandr to set display to use single monitor, even if you have another monitor connected or disconnected

linuxmultiple-monitorsUbuntux-windowsxrandr

xrandr to set display to use single monitor, even if you have another monitor connected or disconnected

I have a laptop that can move and be connected to different monitors etc through out the day.

I usually exit my windows manager and login again every time I disconnect, to have this done automatically for me.

I would like to stay logged in and use the same tool that does the auto-detection and set up or doing it using xrandr. I guess I am just unfamiliar with the different tools available.

  1. With my work secondary monitor connected. I get the following.
xrandr  

Screen 0: minimum 8 x 8, current 3286 x 1080, maximum 32767 x 32767
LVDS1 connected primary 1366×768+0+0 (normal left inverted right x axis y axis) 344mm x 194mm
1366×768 60.0*+
1360×768 59.8 60.0
1024×768 60.0
800×600 60.3 56.2
640×480 59.9
DP1 disconnected (normal left inverted right x axis y axis)
HDMI1 connected 1920×1080+1366+0 (normal left inverted right x axis y axis) 510mm x 287mm
1920×1080 60.0*+ 50.0 59.9
1680×1050 59.9
1600×900 60.0
1280×1024 75.0 60.0
1440×900 59.9
1280×800 59.9
1152×864 75.0
1280×720 60.0 50.0 59.9
1024×768 75.1 70.1 60.0
832×624 74.6
800×600 72.2 75.0 60.3 56.2
720×576 50.0
720×480 60.0 59.9
640×480 75.0 72.8 66.7 60.0 59.9
720×400 70.1
VGA1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)

  1. If I unplug this monitor to move my laptop. I loose every thing on that screen. Its still running but I can see it.

# xrandr
Screen 0: minimum 8 x 8, current 3286 x 1080, maximum 32767 x 32767
LVDS1 connected primary 1366×768+0+0 (normal left inverted right x axis y axis) 344mm x 194mm
1366×768 60.0*+
1360×768 59.8 60.0
1024×768 60.0
800×600 60.3 56.2
640×480 59.9
DP1 disconnected (normal left inverted right x axis y axis)
HDMI1 disconnected 1920×1080+1366+0 (normal left inverted right x axis y axis) 0mm x 0mm
VGA1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
1920×1080 (0x49) 148.5MHz
h: width 1920 start 2008 end 2052 total 2200 skew 0 clock 67.5KHz
v: height 1080 start 1084 end 1089 total 1125 clock 60.0Hz

  1. If I am already logged in I only see the output of the first monitor, even after connecting the second monitor.

# xrandr
Screen 0: minimum 8 x 8, current 1366 x 768, maximum 32767 x 32767
LVDS1 connected primary 1366×768+0+0 (normal left inverted right x axis y axis) 344mm x 194mm
1366×768 60.0*+
1360×768 59.8 60.0
1024×768 60.0
800×600 60.3 56.2
640×480 59.9
DP1 disconnected (normal left inverted right x axis y axis)
HDMI1 connected (normal left inverted right x axis y axis)
1920×1080 60.0 + 50.0 59.9
1680×1050 59.9
1600×900 60.0
1280×1024 75.0 60.0
1440×900 59.9
1280×800 59.9
1152×864 75.0
1280×720 60.0 50.0 59.9
1024×768 75.1 70.1 60.0
832×624 74.6
800×600 72.2 75.0 60.3 56.2
720×576 50.0
720×480 60.0 59.9
640×480 75.0 72.8 66.7 60.0 59.9
720×400 70.1
VGA1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)

Best Answer

You've actually given a fairly good answer that I really can't match up. So, let me explain my use case for xrandr, in hoping that the next person might be able to benefit from us both.

Hopefully my use case for xrandr is a more common one. I plugged in my laptop to HDMI so that I can watch movies from my big TV, but my Xfce isn't giving me any option to turn my laptop's monitor (LVDS) off while watch movies on TV.

So I use

xrandr --output LVDS --off

to turn of my laptop's monitor (LVDS) off, in order to prolong its life. Then use

xrandr --output LVDS --auto

to bring it back after I've done watching movies.

That's my use case. In the case when you've unplugged the monitor from you laptop, but BADLY need to see the apps on the secondary monitor even without one, you can increase virtual X space and just panning with the mouse to there as explained here. For you specific case, it can be:

xrandr --size 1366x768 --panning 3286x1080

It is doable but not practical, that why I emphasized on "BADLY need" :-)

Thanks for your 10 points

Related Question