cctv 0.1.2

Terminal interface for CoolerControl
<div align="center">
  <h1>
  <img alt="cctv_logo" src="https://gitlab.com/caferen/cctv/-/raw/master/assets/cctv.png" width="200">
  <br>
  cctv
  <br>
  </h1>

An experimental terminal client for [CoolerControl](https://gitlab.com/coolercontrol/coolercontrol).

![](assets/demo.webm)
: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/caferen/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/68712421/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/caferen/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.
```

## Configuration

Configuration is optional. `cctv` will attempt to construct configurations from
below locations, in order of preference:

- 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