summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/simple/xwaitforwindow.nix
blob: 41ce65022175626d0e1309a0a60cc2d38a3771fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{ writeDashBin, xdotool, xorg }:
writeDashBin "xwaitforwindow" ''
  # usage: xwaitforwindow ARGS
  # see xdotool search for possible ARGS
  # example: xwaitforwindow -name WINDOWNAME
  set -efu

  if id=$(${xdotool}/bin/xdotool search "$@"); then
    printf 'waiting for window %#x\n' "$id" >&2
    exec ${xorg.xprop}/bin/xprop -spy -id "$id" >/dev/null
  else
    printf 'no window found with xdotool search %s\n' "$*" >&2
    exit 1
  fi
''