I want my console to beep when a task finishes in a terminal I'm not watching.
I actually have it all worked out in Linux:
function beeper_preexec {
focus_window=`xdotool getwindowfocus`
}
function beeper_precmd {
retval=$?
if [[ $focus_window -ne `xdotool getwindowfocus` ]]; then
if [[ $retval -ne 0 ]]; then
beep -f 329.6
else
beep
fi
fi
}
function beeper_setup {
add-zsh-hook precmd beeper_precmd
add-zsh-hook preexec beeper_preexec
}
Does anyone know something I can use to replace xdotool getwindowfocus
on OS X? I don't particularly care if it returns the PID or window id, it just needs to change when the focused window switches.