LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Mobile
User Name
Password
Linux - Mobile This forum is for the discussion of all topics relating to Mobile Linux. This includes Android, Tizen, LiMo, Maemo, MeeGo, Openmoko, Ubuntu Mobile, WebOS, Firefox OS, Open Mobile Alliance and other similar projects and products.
A reminder that LQ now has a dedicated Android sister site: AndroidQuestions.org

Notices

Reply
 
Search this Thread
Old 08-03-2009, 07:31 PM   #1
xflow7
Member
 
Registered: May 2004
Distribution: Slackware
Posts: 158

Rep: Reputation: 21
How to detect external monitor connection on laptop


Hi all,

I have a Lenovo T61p w/ NVIDIA FX570M GPU running Slack 12.2.

I sometimes have an external monitor connected, and like having it set up as a separate Screen in X (i.e. laptop DFP as :0.0 and external as :0.1).

I can do this no problem when the monitor is connected. Only trouble is that if the external monitor is not connected, X won't start unless I either change the default ServerLayout or pass a command-line option.

I'd like to have it automagically figure out whether or not to try and use the second screen.

As far as I can tell, X will not sequentially try ServerLayouts in the xorg.conf file until one works (which would be a really nice feature, IMHO).

So, is there a command that I can have startx (or similar) run to determine if anything is connected and then call X with the appropriate ServerLayout?

I've waded through the /sys and /proc directories, checked every logfile I can think of, and can't find anything that reports the connection status.

Thanks for any help!

Dave
 
Old 08-03-2009, 07:59 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 11,812

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
My first idea would be to parse the output of the xrandr command to see if the monitor is connected.
 
Old 08-03-2009, 08:08 PM   #3
xflow7
Member
 
Registered: May 2004
Distribution: Slackware
Posts: 158

Original Poster
Rep: Reputation: 21
Thanks for the reply.

I don't think that's going to work as I need a way to detect the monitor connection *before* X is started. If X isn't running xrandr returns "Can't open display"
 
Old 08-03-2009, 08:18 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 11,812

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
Your are correct. Will have to work on a second idea.
 
Old 08-04-2009, 09:46 PM   #5
xflow7
Member
 
Registered: May 2004
Distribution: Slackware
Posts: 158

Original Poster
Rep: Reputation: 21
Well, through mostly dumb luck and trial and error I've found *a* way to check I think, although it is not remotely intuitive.

Monitor connected:
Code:
$ cat /sys/devices/virtual/video_output/acpi_video1/state
0000001d
$
Monitor disconnected:
Code:
$ cat /sys/devices/virtual/video_output/acpi_video1/state
0000000d
$
Surely there must be a less arcane check, though!

Last edited by xflow7; 08-04-2009 at 09:48 PM.
 
Old 08-04-2009, 09:50 PM   #6
xflow7
Member
 
Registered: May 2004
Distribution: Slackware
Posts: 158

Original Poster
Rep: Reputation: 21
Aha! That last result got me thinking and it turns out similar info can be obtained by examining:

/proc/acpi/video/VID/CRT0

which is at least *somewhat* more intuitive.
 
Old 08-12-2009, 04:06 AM   #7
Molly83
LQ Newbie
 
Registered: Aug 2009
Posts: 4

Rep: Reputation: 0
Connect the monitor, flat panel, or projector to the laptop's 15-pin video connection on the back of the computer as shown to the right. Once connected, your laptop may automatically switch to the new external display or you may be required to press a sequence of keys in order to switch from the laptop to the external display.i hope this helps
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
external monitor on laptop stu_mueller Slackware 13 04-29-2008 03:00 PM
how use external monitor with laptop? lugoteehalt Linux - Laptop and Netbook 5 02-11-2006 09:35 AM
Will Linux 5.1 detect an external 56kb modem using a USB connection? samnig Linux - Newbie 3 01-13-2005 11:58 PM
Redhat9 doesnt detect my laptop monitor! da_zombie Linux - Laptop and Netbook 6 09-09-2003 10:29 PM
external monitor on a laptop bobterri Linux - Hardware 2 01-14-2003 07:30 PM


All times are GMT -5. The time now is 06:21 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration