From: Jamis Buck Date: 2004-03-25T22:57:06+09:00 Subject: 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. :) -- 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"'