Re: [wmii] Dual-monitor setup

From: Kris Maglione <jg_AT_suckless.org>
Date: Sat, 19 Jan 2008 02:42:45 -0500

You can make this a bit simpler, assuming I understand it correctly:

#!/bin/sh
set -f

if [ -n "$1" ]; then
    DISPLAY=":0.$1"
else
    if [ $DISPLAY == ":0.0" ]; then
       DISPLAY=":0.1"
    else
       DISPLAY=":0.0"
    fi
fi

export WMII_ADDRESS="unix!/tmp/ns.$USER.${DISPLAY%.0}/wmii"

if [ $(wmiir ls /client | grep -v '^sel/$' | wc -l) -eq "0" ];
then
   # no clients open, just warp to upper left corner
   swarp 50 50
else
   client=$(wmiir -a $address read /client/sel/ctl | sed 1q) # sed 1q will be needed in the future
   set -- $(wmiir -a $address read /tag/sel/index | awk '$2 == "'$client'"')
   col=$1
   if [ $col = '~' ]; then
      x=$3
      y=$4
   else
      y=$3
      x=$(wmiir read /tag/sel/index | awk '/^# '$col' / { print $3 }')
   fi
   swarp $(($x+5)) $(($y+5)) # $(()) is valid in POSIX sh, $[] is not
fi

"Beware of bugs in the above code..."

-- 
Kris Maglione
The higher the level of prestige accorded the people
behind the plan, the least less chance there is of
abandoning it.
Received on Sat Jan 19 2008 - 08:42:48 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 16:33:35 UTC