Continuing with Ruby scripts that should probably be written in Bash, here’s one for the eyecandy inclined.
Situation:
- You are running an X stack that supports xrandr 1.2.
- You are running Compiz (Fusion).
- You want to switch back and forth between an external monitor, and your laptop’s display.
A couple of notes. Unfortunately, you cannot trigger an xrandr script on VGA plug/unplug events (yet). See this post. Also, if you are not running an accelerated desktop, or your 2 monitors fit within the bounds defined by a few X components (see this post), you can use your laptop as a secondary monitor.
For now, I’m just toggling between my two monitors via this small Ruby script.
#!/usr/bin/env ruby
def lappy; exec "xrandr --output VGA --off --output LVDS --auto"; end
def external; exec "xrandr --output LVDS --off --output VGA --auto"; end
case ARGV.first
when 'l' then lappy
when 'e' then external
else
external if `xrandr -q`.include?('VGA connected')
lappy
end
And before all you MacHeads out there smile to yourselves about all this work; You thought I forgot about you! I so vary rarely tinker with my desktop setup. This truly is the oddity! Oh, and http://twitter.com/blaine/statuses/153159902