Detecting hardware with Ruby

Here’s a rather off-the-wall question: how would I go about detecting
the presence of external hardware in Ruby? Specifically, sometimes my
laptop is attached to an external monitor, and sometimes it isn’t. Just
before X starts, I’d like to have a Ruby script that runs and checks to
see if the monitor is present, and if it isn’t, chooses a different
server layout from the XF86Config file.

Or is there already a solution to this that I haven’t found?

Thanks. :slight_smile:

···


Jamis Buck
jgb3@email.byu.edu
http://www.jamisbuck.org/jamis

ruby -h | ruby -e
’a=[];readlines.join.scan(/-(.)[e|Kk(\S*)|le.l(…)e|#!(\S*)/) {|r| a <<
r.compact.first };puts “\n>#{a.join(%q/ /)}<\n\n”’

This should be possible with the DDC protocol
http://www.vesa.org/summary/sumvbeddc11.htm

It requires that the driver supports DDC, which I think most
drivers in XFree86 does.

I don’t believe XFree86 will allow you to use DDC without switching to
graphics mode first. Then you can detect if a display is present, and then
you can switch back to good old 80x50 text mode.

I have only tried tweaking XFree86 a little bit, and have absolutely no
idea where go from here.

···

On Thu, 25 Mar 2004 22:57:06 +0900, Jamis Buck wrote:

Here’s a rather off-the-wall question: how would I go about detecting
the presence of external hardware in Ruby? Specifically, sometimes my
laptop is attached to an external monitor, and sometimes it isn’t. Just
before X starts, I’d like to have a Ruby script that runs and checks to
see if the monitor is present, and if it isn’t, chooses a different
server layout from the XF86Config file.


Simon Strandgaard