#!/usr/bin/env sh ## usage: xwin-window-wait [TITLE] ## watches for new windows and returns 0 when new X windows are found ## returns 1 after 5 seconds if no new X clients are found ## use optional argument TITLE to act only if specific window title is found windows_found() { xwininfo -root -tree | fgrep "${@:-}" | wc -l } init_win_count="$(windows_found)" for f in $(seq 50); do [ "$(windows_found)" -gt "$init_win_count" ] && exit 0 sleep 0.1 done exit 1