Dual monitor automation

See the file ~/.config/monitors.xml – this file generally is screwed when you are changing the monitors being connected to your laptop. Most of the times, the symptoms are:

  • connecting to a new environment doesn’t automatically bring up the new monitor on-screen
  • a second VGA monitor is either not detected, or it just doesn’t get the display because: “your display resolution is only XYZ
    whereas you are trying to set a display resolution of ABC”
  • you can only set mirror display and not “dual display” as it should be

Since all of these problems are so chronic, you may want to consider doing away with your dual monitor automation (that gnome’s display applet provides) and using xrandr+customized X configuration. That would require you to use a script that you might have to run every time you change the number of monitors (like connecting a new one etc.). I wanted to believe that openSUSE 11.2 doesn’t need this any more, but I don’t think we’re there yet, since if you are traveling around with your laptop connecting to different resolution screens, it doesn’t work out of the box.

Or – delete the monitors.xml file every time you want to change resolutions. It’s still hacky.

For anyone who wants to try out the dual display script I use, here it is (copy paste this somewhere and save as dual-display.sh and chmod a+x on that file).

#!/usr/bin/sh

# Rishi Pande
# http://fryol./net
# dual-display.sh-0.0.3
# This works well on openSUSE 11.0 / Compaq nc6400, please report if it ain't
# working or even if it works elsewhere.

app=dual-display

if [ "x$1" != 'x-h' ];
   then
   dual_disp_resolution=$1;
else
   dual_disp_resolution=1440x900;
fi;

directions="\\n\
# You should make sure that you see similar settings\\n\
# enabled in the Display sub-section of /etc/X11/xorg.conf: \\n\
#     Virtual    2880 900 \\n\
# And these in the monitor sub-section \\n\
#     Option       \"PreferredMode\" \"1440x900\" \\n\
#     Option       \"Xinerama\" \"off\" \\n"

if [ "x$1" = "x-h" ];
   then
   echo "Usage: $app.sh [WIDTHxHEIGHT]";
   echo "$app: In case you want to undo things, plug out your laptop from the";
   echo "$app: docking station (or pull out the VGA cable) and run $app.sh again.";
   echo "$app: To use a different resoltion, please supply WIDTHxHEIGHT (like 1280x800)";
   echo "$app: as an arguement to the script, and if your /etc/X11/xorg.conf is fine,";
   echo "$app: things should work. Note that this resolution is for your VGA.";
   echo -ne "$app: These are the relevant settings in /etc/X11/xorg.conf:\n";
   grep Virtual /etc/X11/xorg.conf
   #echo -ne "\n$app: "
   grep -E 'Option.*Xinerama' /etc/X11/xorg.conf
   #echo -ne "\n$app: "
   grep -E 'Option.*PreferredMode' /etc/X11/xorg.conf
   echo -ne $directions
   exit;
fi;

if [  `xrandr --prop|grep ' connected'|wc -l` -gt 1 ];
   then
   xrandr --output VGA --preferred --mode $dual_disp_resolution --right-of LVDS;
   # With suse 11.0, this is no longer needed:
   #  xrandr --output VGA --left-of LVDS;
   #  xrandr --output VGA --right-of LVDS;
   #  dcop kwin KWinInterface reconfigure;
   else
   xrandr --output VGA --off;
fi;

Leave a Reply

Your email address will not be published. Required fields are marked *