# libtmux._internal.control_mode.ControlMode

- **Module:** libtmux._internal.control_mode
- **Package:** libtmux
- **Language:** Python
- **Kind:** class
- **Source:** https://github.com/tmux-python/libtmux/blob/9fdd083a8181a827889337b63cd4e6daea661a8c/src/libtmux/_internal/control_mode.py#L25
- **Page:** https://libtmux.org/en/py/latest/reference/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.
