# libtmux._internal.control_mode.ControlMode

- **Module:** libtmux._internal.control_mode
- **Package:** libtmux
- **Language:** Python
- **Kind:** class
- **Source:** https://github.com/tmux-python/libtmux/blob/036c521c4b83ce6e434eb50afe2a0d08a6a05e46/src/libtmux/_internal/control_mode.py#L25
- **Page:** https://libtmux.org/reference/py/libtmux-_internal-control_mode-controlmode/

Context manager that spawns a tmux control-mode client.

Creates a real client attached to the session, visible in
``Server.list_clients()``. The client communicates via the tmux
control protocol on stdout.

While active, ``Server.list_clients()`` will include this client.

## Example

```python
>>> with ControlMode(server=server, session=session) as ctl:
...     clients = server.list_clients()
...     assert len(clients) > 0
...     assert ctl.client_name != ''
```

## Members

- `server` (attribute)
- `session` (attribute)
- `client_name` (attribute)
- `stdout` (attribute)
- `_proc` (attribute)
- `_write_fd` (attribute)
- `__init__` (method)
- `__enter__` (method) — Spawn control-mode client and wait for registration.
- `__exit__` (method) — Terminate control-mode client.
