# libtmux._internal.control_mode.ControlMode

- **Module:** libtmux._internal.control_mode
- **Package:** libtmux
- **Language:** Python
- **Kind:** class
- **Source:** https://github.com/tmux-python/libtmux/blob/38e368c11117fb4aeb2f082d552cd4f210eae06a/src/libtmux/_internal/control_mode.py#L23
- **Page:** https://libtmux.org/en/py/stable/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.

## Examples

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

## Members

### Other members

- [`client_name`](/en/py/stable/reference/libtmux-_internal-control_mode-controlmode-client_name/) (attribute)
- [`server`](/en/py/stable/reference/libtmux-_internal-control_mode-controlmode-server/) (attribute)
- [`session`](/en/py/stable/reference/libtmux-_internal-control_mode-controlmode-session/) (attribute)
- [`stdout`](/en/py/stable/reference/libtmux-_internal-control_mode-controlmode-stdout/) (attribute)
- [`__enter__`](/en/py/stable/reference/libtmux-_internal-control_mode-controlmode-__enter__/) (method): Spawn control-mode client and wait for registration.
- [`__exit__`](/en/py/stable/reference/libtmux-_internal-control_mode-controlmode-__exit__/) (method): Terminate control-mode client.
- [`__init__`](/en/py/stable/reference/libtmux-_internal-control_mode-controlmode-__init__/) (method)
- [`_proc`](/en/py/stable/reference/libtmux-_internal-control_mode-controlmode-_proc/) (attribute)
- [`_write_fd`](/en/py/stable/reference/libtmux-_internal-control_mode-controlmode-_write_fd/) (attribute)
