# LibTmux.watch_screen

- **Module:** LibTmux
- **Package:** LibTmux
- **Language:** Julia
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-julia/blob/1a68a11f071686736937d027b190b43cf946c385/src/screen_wait.jl#L225
- **Page:** https://libtmux.org/en/julia/latest/reference/libtmux-watch_screen/

```
watch_screen(
    f,
    server::LibTmux.Server,
    pane::LibTmux.PaneRef;
    interval,
    timeout,
    cancel,
)
```

## Methods

Take the entry read of `pane`'s visible screen, call `f(screen)` with a [`ScreenWatch`](/en/julia/latest/reference/libtmux-screenwatch/) and return its value. Keys sent inside `f` cannot be counted as already on the entry screen, so a block can act and then wait:

```julia
watch_screen(f, server::Server, pane::PaneRef; interval=0.1, timeout=5.0,
             cancel=nothing)
```



```julia
watch_screen(server, pane) do screen
    send_keys(server, pane, "echo ready", "Enter")
    wait_for_text(screen, "ready")
end
```

`timeout` is one total deadline from the entry read, shared by every wait in the block; `interval` is the pause between reads. `cancel` is a [`CancellationToken`](/en/julia/latest/reference/libtmux-cancellationtoken/). Every wait in the block counts against the entry read taken when the block opened, so repeat the same text only with a new `watch_screen`. The entry read raises [`ScreenWaitEnded`](/en/julia/latest/reference/libtmux-screenwaitended/) when the pane or server is already gone. A `pane` from another server, or from an earlier generation of this one, raises `CrossServerReference` or `StaleReference`. The handle is not valid after `f` returns.

## Parameters

- `f` (`Any`)
- `server` (`LibTmux.Server`)
- `pane` (`LibTmux.PaneRef`)
- `interval` (`Real`)
  Default: `0.1`.
- `timeout` (`Real`)
  Default: `5.0`.
- `cancel`
  Default: `nothing`.

## Guides

Pages that discuss `watch_screen`.

- [Observing output](/en/julia/latest/topics/observations/)
