OctOpenBSD - scriptomancy

Two screens

The sound of the machine monks' horn rings again.


A fair number of October related events have intertwined. There's the inktober, there's the spooktober, there's the oektober and now there's octOpenBSD[tober].

I took this opportunity to combine them all into one unix_surrealism month. I am not yet fully certain what this might mean, but some steps have already been taken.

I'm going to spend the month with OpenBSD exclusively. This means my digital gimpism will take a hit, since the drawing tablet I have is supported 'just about.' And 'just about' is exactly enough for uxn's oekaki. I said it before, pressure sensitivity spoils. Anyway...

I set the horned desktop aside, and put in its place my beloved X201, stuck it in a dock, connected a keyboard, printer, and notably an external VGA monitor.

To celebrate, I hacked together a small ksh script that cycles through your connected monitors (as long as there are two and two only).

#supported options for "where": --left-of --right-of --below --above
#comment out "where" to simply mirror the screens

active_monitors=$(xrandr --listactivemonitors | cut -d ' ' -f6)
all_monitors=$(xrandr | grep ' connected' | cut -d' ' -f1)
first_monitor=$(print $all_monitors | cut -d ' ' -f1)
second_monitor=$(print $all_monitors | cut -d ' ' -f2)

xr() {
  xrandr --output $1 --$2 $5 $6 --output $3 --$4

if [[ $where != "" ]]; then of=$second_monitor; fi

case $(print $active_monitors) in

  $(print $all_monitors)) print "both are on";
    xr $first_monitor auto $second_monitor off;;
  $first_monitor) print "first is on";
    xr $first_monitor off $second_monitor auto;;
  $second_monitor) print "second is on";
    xr $first_monitor auto $second_monitor auto $where $of;;
  *) print "no match";;


direct download

The program checks what monitors are connected to the machine, and then cycles through the three options:

As a bonus I added the variable "where" which let's you define relative position of the second monitor from the first one.

Beware the spiked octopus.