config

OpenBSD system configuration
git clone git://jacobedwards.org/config
Log | Files | Refs | README

commit 48d8f03ef01be2f269efa347f734cbf895b76b2b
parent b1bfe7c26e269cbbc4c23c4a160b93e73d2ca1ad
Author: Jacob R. Edwards <n/a>
Date:   Tue,  2 Nov 2021 16:01:55 -0700

Improve X display management script

Support any number of displays and those not specified get turned
off instead of being left as is.  Only tested with two displays.

Diffstat:
Mlocal/bin/bin/dp | 32++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/local/bin/bin/dp b/local/bin/bin/dp @@ -1,16 +1,24 @@ -#!/bin/sh +#!/usr/local/plan9/bin/rc -e # Copyright 2021 Jacob R. Edwards # License: GPLv3 # -# dp -- manage multi-monitor setup -# -# Each argument is taken as a display, if two are given the first is -# put to the left of the second, otherwise if only one is given that -# display is turned off. +# dp -- manage monitors on X11 + +if (~ $#* 0) + xrandr --auto +if not { + nots = `{ + xrandr --current | awk '$2 == "connected" { print $1 }' | \ + egrep -v '^(' ^ `{ echo $* | tr ' ' '|' } ^ ')$' + } && args = ('--output '^$nots --off) + + while (! ~ $#* 1) { + args = ($args --output $*(1) --auto --left-of $*(2)) + shift + } + args = ($args --output $*(1) --auto) + + eval xrandr $args +} -case $# -in - 2) xrandr --auto --output "$1" --left-of "$2" --auto;; - 1) xrandr --output "$1" --off;; - *) printf 'usage: %s [output [output]]\n' `basename $0` 1>&2; exit 1;; -esac +setbg