master hovercats/bin / rc / watcher
 1#!/bin/rc
 2
 3flag e +
 4
 5# Pipe from wew recieve events
 6while(ev=`{read -n 1}) {
 7	switch($ev(1)) {
 8		case MAP
 9			# Attempt to focus on the newly mapped window
10			wattr o $ev(2) || focus $ev(2)
11		case CREATE
12			# Attempt to focus on the newly created window
13			# Fallback for unregistered MAP events
14			wattr o $ev(2) || focus $ev(2)
15		case UNMAP
16			# Attempt to regain focus when windows are unmapped
17			test ! `{pfw} && focus top
18		case DESTROY
19			# Attempt to regain focus when windows are killed
20			# Fallback for unregistered UNMAP events
21			test ! `{pfw} && focus top
22	}
23}