<div align="center">
<h1>
<img alt="cctv_logo" src="https://gitlab.com/coolercontrol/cctv/-/raw/master/assets/cctv.png" width="200">
<br>
cctv
<br>
</h1>
A terminal client for [CoolerControl](https://gitlab.com/coolercontrol/coolercontrol).

:warning: Requires the CoolerControl service daemon to be running either locally or remotely, [see Configuration](#configuration).
</div>
[[_TOC_]]
## Building
Clone the git repo and build with cargo. Requires a working [Rust installation](https://www.rust-lang.org/tools/install).
```bash
git clone https://gitlab.com/coolercontrol/cctv.git
cd cctv
cargo build --release
cargo run --release
```
## Installing/Upgrading
There are no packages for distributions yet but you can download and install the
latest binary artifact built from master or build from source yourself.
### Latest release
```bash
curl -LOJ --clobber --output-dir "/tmp" \
https://gitlab.com/api/v4/projects/69657520/packages/generic/master/latest/cctv
sudo install -Dm 755 /tmp/cctv -t /usr/bin
```
### From source
Install with cargo. Requires a working [Rust installation](https://www.rust-lang.org/tools/install).
```bash
cargo install --git https://gitlab.com/coolercontrol/cctv.git
```
### From crates.io
`cctv` is also published to crates.io. Note that the version there may be slightly outdated.
```bash
cargo install cctv
```
Make sure `$HOME/.cargo/bin` is in your path:
```bash
# Bash users
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
# zsh users
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
```
## Usage
### CLI
While primarily a TUI application, `cctv` also has a command line interface for some common operations.
```None
Usage: cctv [OPTIONS]
TUI client for CoolerControl
Options:
--list-modes, -l Lists all available modes.
--activate-mode <mode-name>, -a <mode-name> Activates the specified mode.
--delay-by <seconds> When used in conjunction with --activate-mode, sets
the delay in seconds before the mode switch.
--help, -h Shows this help message.
If no options are passed, the application will launch into the TUI.
```
### TUI
Keybindings:
```
Down, e, j: Select next item
Up, i, k: Select previous item
Right, o, l: Go to the next page
Left, n, h: Go to the previous page
R: Refresh app data
s: Toggle legend visibility on charts.
Ctrl+q: Quit
```
#### Devices Page
Additional keybindings:
```
a: Toggle between the default and the alternative chart.
```
#### Modes Page
Additional keybindings:
```
Enter: Activate the currently highlighted mode.
```
#### Profiles Page
##### Editing profiles
Profile editing is a work-in-progress. There's experimental support for
manipulating graph and fixed profiles.
:warning: Take a backup of your config before editing - there may be breakages.
There are two input modes: edit and normal. Normal mode is the default.
When you enter edit mode you will see a popup populated with the current
settings.
Edits are in one of three states: working, saved, and applied.
- Working changes are the changes you made but haven't saved within `cctv`.
These aren't visualized anywhere but in the text box.
- Saved changes are the changes saved in `cctv` but haven't been submitted to
CoolerControl. These will be used for drawing the graphs but won't be
effective until applied.
- Applied changes are final and have been successfully sent to the daemon.
:light_bulb: Your changes are kept (without being saved) when moving between
edit and normal modes.
Changes are validated when moving between stages.
- working -> saved: all syntactially correct changes are accepted.
- saved -> applied: all changes deemed valid by the daemon are accepted.
There are no guard rails beyond these. You will be notified of any errors. Lack
of a notification indicates success.
:light_bulb: To discard saved changes: press 'R' to sync `cctv` with the daemon.
:warning: Note that the official GUI will not update automatically. You will
need to refresh the page to see the changes there. The reverse is also true.
Additional keybindings when in normal mode:
```
E: Enter edit mode.
D: Discard working changes.
A: Apply saved changes to the daemon.
```
Additional keybindings when in edit mode:
Following characters can be inserted:
- digits
- space
- .
- ,
- [
- ]
```
Esc: Exit edit mode.
Enter: Save working changes.
D: Discard working changes.
Right, o, l: Move cursor to the right.
Left, n, h: Move cursor to the left.
Backspace: Delete one character.
```
## Configuration
Configuration is optional. `cctv` will attempt to construct configurations from
below locations, in order of precedence:
- Environment variables listed [below](#environment-variables).
- `coolercontrold` configuration file
- CoolerControl defaults
This means that if you're overriding CoolerControl's defaults, `cctv` will
automatically pick _some of_ them up. But you can still override them specifically for
`cctv` with the environment variables e.g. to have `cctv` connect to a remote
CoolerControl instance instead of your local daemon.
Note that there's currently no SSL or IPv6 support.
### Environment variables
- `CCTV_DAEMON_PORT` - The port CoolerControl is listening on. CoolerControl default: 11987
- `CCTV_DAEMON_ADDRESS` - The address CoolerControl is listening on. CoolerControl default: 127.0.0.1
- `CCTV_DAEMON_CONFIG_FILE_PATH` - The path to CoolerControl's config file. CoolerControl default: /etc/coolercontrol/config.toml
- `CCTV_TIME_RANGE` - Time range in seconds to look back to for device charts. cctv default: 60
- `CCTV_USERNAME` - CoolerControl username if you've set one. Otherwise the internal default is used.
- `CCTV_PASSWORD` - CoolerControl password if you've set one. Otherwise the internal default is used.
- `CCTV_NO_SPLASH` - Skips the splash screen when set to true. cctv default: false