Switching display between external and internal monitor

Opensuse 11.3
KDE 4.4.4
ati radeon 4330 with default driver - nouveau (although laptop has hybrid graphics i was eventually forced to switch intel off, because automatic switching dont work with X and both systems are consuming power - but this is another story)

Ill describe 2 use cases how it should work:

  1. power cable unplugged - when I plug in the external monitor it should automatically create another screen acting as extension to internal monitor’s screen.
    If i close the lid it should go to standby.
  2. power cable plugged in - when I plug in the external monitor it should automatically create another screen acting as extension to internal monitor’s screen as before, but
    If i close the lid it should redirect the screen from internal monitor to external monitor, disabling internal display. Opening the lid should act vice versa.
    Also when i unplug the external monitor it should disable the external monitors screen to avoid window creation to that screen.

By example this behavior works with windows 7 out-of-the-box if my explanation was a bit vague.

I have read similar threads which recommend looking into randr, which i did, but havent found a good solution.(randr doesn’t know when the lid is closed or open)

Thank you for your attention.

best i’ve found so far is the following:

#!/bin/sh
xrandr --output LVDS1 --auto --output VGA1 --auto
sleep 2
xrandr --output LVDS1 --off --output VGA1 --auto

this seems to be the most bug-free way of swapping monitor display for dual screen setups.

first line sets output to both (mirror).
sleep 2 = second delay - seems to be required as xrandr/X crashes more often if you change monitor setup too quickly.
second xrandr line disables laptop LCD and keeps the external display active.

you’ll need to run xrandr -q to populate your screens’ names.

not fully automatic (i’ve yet to find a way to detect system events that i fully understand) but a simple double click process on a file :slight_smile:

Opensuse 11.3
KDE 4.4.4
ati radeon 4330 with default driver - nouveau (although laptop has hybrid graphics i was eventually forced to switch intel off, because automatic switching dont work with X and both systems are consuming power - but this is another story)

Can you please explain in more detail how you disabled your intel chipset? There is another thread here where this is issue. The OP in that thread wnated to get HDMI support which may require the nvidia driver/chipset.

I dont believe this will help, but I turned it off from BIOS using the “DISCRETE” setting. So nothing fancy.

Ok, thanks.

This is my success story, I hope, it might be helpful for some people:)

OpenSuse 11.3, Hp Compaq nx7400, Intel graphic chip: I spent several hours trying to get dual display (a laptop LCD and an external VGA) to work with xrandr, nothing worked, experienced several X crashes etc.

Then I’d temporarily switched off the composite desktop effects (Shift+Alt+F12), which were on per default after a fresh OpenSuse 11.3 installation and, lo and behold, everything started to work as expected. I went then to KDE System Settings/Display Settings (the actual English names may differ, I’m sitting in the front of a Polish KDE GUI) and set LVDS1 to 1280x800, left of VGA1 (1280x1024), and that was is.

Here is my lspci and xrandr output:

akisnb2:~ # lspci | grep 945
00:00.0 Host bridge: Intel Corporation Mobile 945GM/PM/GMS, 943/940GML and 945GT Express Memory Controller Hub (rev 03)
00:02.0 VGA compatible controller: Intel Corporation Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller (rev 03)
00:02.1 Display controller: Intel Corporation Mobile 945GM/GMS/GME, 943/940GML Express Integrated Graphics Controller (rev 03)
10:00.0 Network controller: Intel Corporation PRO/Wireless 3945ABG [Golan] Network Connection (rev 02)

akisnb2:~ # xrandr
Screen 0: minimum 320 x 200, current 2560 x 1024, maximum 4096 x 4096
VGA1 connected 1280x1024+1280+0 (normal left inverted right x axis y axis) 376mm x 301mm
   1280x1024      60.0*+   75.0  
   1152x864       75.0  
   1024x768       75.1     70.1     60.0  
   832x624        74.6  
   800x600        72.2     75.0     60.3     56.2  
   640x480        72.8     75.0     66.7     60.0  
   720x400        70.1  
LVDS1 connected 1280x800+0+0 (normal left inverted right x axis y axis) 289mm x 210mm
   1280x800       60.1*+
   1024x768       60.0  
   800x600        60.3     56.2  
   640x480        59.9  
TV1 disconnected (normal left inverted right x axis y axis)


Well done!

Building up on yesterday’s discovery, I’ve put a simple bash script into ~/.kde4/Autostart and it works for me like charm. Perhaps some gurus here might want to customize it for their purposes:

#!/bin/bash

# outputs for intel chipset may be "VGA1" (external VGA), or "LVDS1" (laptop lcd), or "DVI-0", or "TMDS-1"
EXTERNAL_OUTPUT="VGA1"
INTERNAL_OUTPUT="LVDS1"

#checking, if VGA1 connected
xrandr |grep $EXTERNAL_OUTPUT | grep " connected "

if  $? -eq 0 ]; then
   #switching off compositing desktop effects
   qdbus org.kde.kwin /KWin org.kde.KWin.toggleCompositing
   #enabling external display
   xrandr --output $EXTERNAL_OUTPUT --mode 1280x1024
   #enabling laptop lcd left of external vga
   xrandr --output $INTERNAL_OUTPUT --auto --left-of  $EXTERNAL_OUTPUT 
#else: laptop lcd only, nothing to do, desktop effects stay enabled
fi

Also, the best source of knowledge on this topic I’ve found so far is the documentation on the ThinkWiki, beware the part about the limitations of Intel chipsets: Xorg RandR 1.2 - ThinkWiki

Besides, I didn’t write my own xorg.conf.