Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Using Fedora
FedoraForum Search

Forgot Password? Join Us!

Using Fedora General support for current versions. Ask questions about Fedora and it's software that do not belong in any other forum.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 9th April 2009, 02:06 PM
keegan Offline
Registered User
 
Join Date: Apr 2009
Posts: 17
Question How to tell if VGA monitor is attached before X starts

Hi all. I just upgraded from F8 to f10, and after an entire day's worth of fiddling, i finally got my dual monitor setup working. I'm using a laptop with one external vga monitor.

Everything with the dual head works perfectly, except for when i try to boot up without the external monitor plugged in. X seems to hang at the start, i can't use the ctrl+alt+f keys or anything.

I've noticed that removing my xorg.conf file and rebooting lets me boot up just fine without the external monitor.

So, my question is, how can i automate that? My initial guess was to parse the output from xrand -q, see if the vga monitor is attached, and either copy/remove the dual head xorg.conf file. However, xrandr doesn't seem to work unless X is already running.

RIght now I boot in to single user mode and move it myself, which is a pain.

Here's some information:

xorg.conf
Code:
Section "Device"
        Identifier      "Intel 945G "
        Driver         "intel"

        Option          "monitor-LVDS" "bar"
        Option          "monitor-VGA" "foo"
        #required for a virtual size > 2048x2048
        Option          "NoAccel"
        #i dont think this does anything
        Option          "MonitorLayout" "CRT,LVDS"
EndSection

Section "Monitor"
        Identifier      "foo"
        Option "LeftOf"  "bar"

EndSection

Section "Monitor"
        Identifier      "bar"
EndSection

Section "Screen"
        Identifier      "Default Screen"
        Device        "Intel Corporation 945G Integrated Graphics Controller"
        Monitor       "bar"
        DefaultDepth  24
        SubSection "Display"
                Depth          24
                Modes         "1280x1024"  "1280x768" "1024x768"   "640x480"
                Virtual                 2560 1024
        EndSubSection
EndSection
output from lspci (with second monitor attached):
Quote:
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)
Output from xrandr -q:
Quote:
Screen 0: minimum 320 x 200, current 2560 x 1024, maximum 2560 x 1024
VGA connected 1280x1024+0+0 (normal left inverted right x axis y axis) 375mm x 301mm
1280x1024 60.0*+ 75.0 60.0*
1280x960 75.0 70.0 60.0
1152x864 75.0 70.0 60.0
1024x768 75.0 70.1 60.0
832x624 74.6
800x600 72.2 75.0 60.3 56.2
640x480 75.0 72.8 75.0 66.7 59.9
720x400 70.1
LVDS connected 1280x800+1280+0 (normal left inverted right x axis y axis) 304mm x 190mm
1280x800 60.0*+
1024x768 60.0
800x600 60.3
640x480 59.9
TMDS-1 disconnected (normal left inverted right x axis y axis)
TV disconnected (normal left inverted right x axis y axis)
And finally, every time i boot, i run the following command:
xrandr --output VGA --left-of LVDS


If anyone has recommendations as to how I can automate switching between single / dual head configs, please let me know.
Reply With Quote
  #2  
Old 9th April 2009, 04:55 PM
sideways's Avatar
sideways Offline
Retired User
 
Join Date: Oct 2004
Location: London, UK
Posts: 4,999
Have you tried setting the monitors with gnome-display-properties? (writes a monitors.xml config file to ~/.config/)

Otherwise, before X starts you can check for monitors with something like (as root)

Code:
X -configure &>/dev/null && grep Monitor xorg.conf.new
Reply With Quote
  #3  
Old 9th April 2009, 05:26 PM
keegan Offline
Registered User
 
Join Date: Apr 2009
Posts: 17
Quote:
Originally Posted by sideways View Post
Have you tried setting the monitors with gnome-display-properties? (writes a monitors.xml config file to ~/.config/)

Otherwise, before X starts you can check for monitors with something like (as root)

Code:
X -configure &>/dev/null && grep Monitor xorg.conf.new
I haven't been using gnome, i'm using kde, but changing the default session to gnome doesn't help anything at boot.


I tried using teh X -configure tool. It create a new xorg.conf file. It only lists one monitor when i'm in single user mode. It only lists one monitor when i'm fully booted, too. they're no different.

Any other ideas?
Reply With Quote
  #4  
Old 9th April 2009, 07:51 PM
sideways's Avatar
sideways Offline
Retired User
 
Join Date: Oct 2004
Location: London, UK
Posts: 4,999
If you're not using x86_64 then you might be able to run ddcprobe.

It's deprecated in Fedora but since it's just a binary and one shared lib you can install these two rpms:

http://rpm.pbone.net/index.php3/stat....i586.rpm.html
http://rpm.pbone.net/index.php3/stat....i586.rpm.html

unfortunately, it only works in 32bit, in x86_64 you'll probably get this:

Code:
$ ddcprobe
VESA BIOS Extensions not detected.
(There are a few bug reports about it, eg here)
Reply With Quote
  #5  
Old 9th April 2009, 09:38 PM
keegan Offline
Registered User
 
Join Date: Apr 2009
Posts: 17
Thanks for the suggestions thus far, sideways. I installed ddprobe / libve at your recommendation, however, ddcprobe seg faults:

#>sudo ddcprobe -v
vbe: VESA 3.0 detected.
Segmentation fault

ldd reports all libraries found.


I'm running 32 bit f10. I downloaded the ddcprobe-2.0-alt1.i586.rpm version. I have an intel based laptop.

Last edited by keegan; 9th April 2009 at 09:41 PM.
Reply With Quote
  #6  
Old 9th April 2009, 09:55 PM
sideways's Avatar
sideways Offline
Retired User
 
Join Date: Oct 2004
Location: London, UK
Posts: 4,999
I used to get that with vbetool, I can't remember how it was fixed, but make sure you run ddcprobe from a virtual console or init 3. Also install vbetool (via yum) and test that is working. Also there may be a newer version of ddcprobe available.

eg

http://rpm.pbone.net/index.php3/stat....i586.rpm.html
http://rpm.pbone.net/index.php3/stat....i586.rpm.html

failing that, I'm still not clear about why you can't use xrandr to configure the monitors after boot, doesn't kde have an equivalent to gnome-display-properties? Are you saying that xrandr fails to set up the screens the way you desire?
Reply With Quote
  #7  
Old 9th April 2009, 11:32 PM
keegan Offline
Registered User
 
Join Date: Apr 2009
Posts: 17
the issue isn't getting it to work after logging in, i can do thatr. the problem is if i have my dual xorg.conf in place when the secondary monitor isnt attached, x freexes before the login screen. ddcprobe gives me access denied in single user mode. i'll try the veb one.
Reply With Quote
  #8  
Old 9th April 2009, 11:56 PM
sideways's Avatar
sideways Offline
Retired User
 
Join Date: Oct 2004
Location: London, UK
Posts: 4,999
so you mean that if you don't use the xorg.conf then xrandr can't setup the displays.

I just tried it and xrandr doesn't work for me either, I can only clone the screens
Reply With Quote
  #9  
Old 10th April 2009, 12:04 AM
keegan Offline
Registered User
 
Join Date: Apr 2009
Posts: 17
kinda. I can boot just fine with no xorg.conf. I can boot just fine with my xorg.conf when i have an external monitor attached. I cant boot when i use my xorg.conf file and [i]dont['i] have an external monitor attached.

The way i get around it for now is when i dont have an external monitor, i boot in to single user mode, remove the xorg.conf, and then boot all the way in to X. I'd like to automate that, but the trouble is determining when to do it. If i have an extrernal monitor, i don't need to. but if its missing, then i do.
Reply With Quote
  #10  
Old 10th April 2009, 12:22 AM
sideways's Avatar
sideways Offline
Retired User
 
Join Date: Oct 2004
Location: London, UK
Posts: 4,999
It's a tricky one, hal handles all the hardware detection now but when I type 'lshal' I can't find any mention of the second monitor, just the lcd panel on the laptop.

So my feeling is that you can't detect the second display. I have an nvidia card and I also tried using that to detect the displays, no luck.

looks like the manual xorg.conf setup is the only solution for now. A partial solution would be to have two entries in grub "Single Monitor Boot" and "Dual Monitor Boot" then have a startup script check which one was chosen and copy or remove xorg.conf as required before the Xserver starts (you could add some dummy parameter to the kernel boot options for one of the entries and then check if it's present in 'cat /proc/cmdline', eg just append '5' to one of the kernel lines, that'll boot into init 5 as normal but 'cat /proc/cmdline' will have a 5 at the end)
Reply With Quote
  #11  
Old 10th April 2009, 12:24 AM
keegan Offline
Registered User
 
Join Date: Apr 2009
Posts: 17
yeah, i thought about doing that. At least that way i dont have to go through the steps of doing it manually.

Thanks for all your help, i really appreciate it.
Reply With Quote
  #12  
Old 13th April 2009, 05:44 PM
keegan Offline
Registered User
 
Join Date: Apr 2009
Posts: 17
I got around to doing this today and I thought i'd share the process in case anyone else needs it.

You'll need to title your dual monitor xorg.conf as /etc/X11/xorg.conf.dual, or you can edit the script appropriately. It also assumes you don't want an xorg.conf if you don't have an external monitor, so you might want to change the 'rm' part in the script to do a copy.

1. Create a script to copy the xorg.conf files (put it in /etc/init.d, chmod it 755, and chown to root:root . I called mine 'xorgswitch'
Code:
#!/bin/bash                                                         

#/etc/init.d/xorgswitch
#+ keegan morrison [ keegster at gmail dot com ]
#+ i'm not responsible for any outcomes of this script
#+ note it does delete some files, be sure to read every line before executing this script!

# chkconfig: 2345 7 80
# description: Switches the xorg.conf file depenging which kernel was booted


#this assumes the word 'dual' is in /proc/cmdline
#+ to add it, put it on the kernel line you want to boot 
#+ in /etc/grub.conf like this:                          
#+ kernel /vmlinuz-2.6.27.21-170.2.56.fc10.i686 ro root=/dev/VolGroup00/LogVol00 rhgb quiet dual
#if the word dual isn't in there, then assume we want to run the single monitor xorg.conf       
start(){                                                                                        
        grep -q dual /proc/cmdline                                                              
        if [ $? -eq 0 ];                                                                        
        then                                                                                    
                cp /etc/X11/xorg.conf.dual /etc/X11/xorg.conf                                   
                RETVAL=$?;                                                                      
        else                                                                                    
                #i don't use an xorg.conf when i dont use an external                           
                #+monitor, so i delete mine. You might want to copy one                         
                #+, like xorg.conf.single, instead od deleting it.
                rm -f /etc/X11/xorg.conf
                RETVAL=$?;
        fi
}
stop(){
        #make a backup of the current one, just in case some changes were made.
        cp /etc/X11/xorg.conf /etc/X11/xorg.conf.bak
}

RETVAL=0;

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  reload|restart)
        stop
        start
        ;;
  status)
        #since its not really a service, just return 0
        RETVAL=0
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|reload|status}"
        exit 1
esac
exit $RETVAL
Now, update /etc/grub.conf to contain one new entry, and also the initial entry. I copied the second one, made it the first, and added the word 'dual'. The entries are identical except for the word dual in one, and the titles. Be sure to make a backup before you edit yours in case it breaks.

Code:
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,1)
#          kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
#          initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,1)/grub/splash.xpm.gz
hiddenmenu
title Fedora Dual Monitor (2.6.27.21-170.2.56.fc10.i686)
        root (hd0,1)
        kernel /vmlinuz-2.6.27.21-170.2.56.fc10.i686 ro root=/dev/VolGroup00/LogVol00 rhgb quiet dual
        initrd /initrd-2.6.27.21-170.2.56.fc10.i686.img
title Fedora Single Monitor (2.6.27.21-170.2.56.fc10.i686)
        root (hd0,1)
        kernel /vmlinuz-2.6.27.21-170.2.56.fc10.i686 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
        initrd /initrd-2.6.27.21-170.2.56.fc10.i686.img
Now, when you boot, you'll see two boot options, one titled Fedora Dual Monitor, and one titled Fedora Single Monitor.

All thats left is to import the service.

chkconfig --add xorgswitch

That should be it. Hopefully you can now run chkconfig, and see the new script called xorgswitch. Now Make any additional backups you think you might need, and reboot. Select whichever boot option you want and voila, single or dual monitor setup in a pinch.
Reply With Quote
Reply

Tags
attached, monitor, starts, vga

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Monitor 'Out of Range' When Anaconda Starts markhibberd Installation and Live Media 4 17th May 2008 10:01 AM
no monitor attached -> X keeps crashing tnxlabs Using Fedora 0 14th January 2008 04:40 PM
Only boots with monitor attached shepimport Using Fedora 4 8th September 2007 07:12 PM


Current GMT-time: 08:52 (Wednesday, 19-06-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat