Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ The app lists other NZXT devices as "no driver yet". If you have one, *Settings
### Windows

1. Quit NZXT CAM, and turn it off in *Task Manager → Startup apps* so it does not come back at the next logon. While CAM's app runs, it holds the devices and camless cannot open them. CAM Service can keep running.
2. Run [camless-setup.exe](https://github.com/kleju13/camless/releases/latest/download/camless-setup.exe). It needs no administrator rights. It is not code-signed, so SmartScreen may stop it: *More info → Run anyway*. Or install from PowerShell, which also checks the download's SHA-256:
2. Run [camless-setup.exe](https://github.com/kleju13/camless/releases/latest/download/camless-setup.exe). It asks for administrator rights and installs in `C:\Program Files\camless`. It is not code-signed, so SmartScreen may stop it: *More info → Run anyway*. Or install from PowerShell, which also checks the download's SHA-256:
```
irm https://raw.githubusercontent.com/kleju13/camless/main/scripts/install.ps1 | iex
```
Expand All @@ -104,7 +104,7 @@ The app lists other NZXT devices as "no driver yet". If you have one, *Settings

The app checks for a new release each time it starts and shows *Update available* under the service in the sidebar. *Update* there, or in *Settings → About*, installs it. Uninstall camless from *Settings → Apps* in Windows. It keeps your settings in `%APPDATA%\camless` unless you choose to delete them.

CPU temperature also needs [PawnIO](https://pawnio.eu) and its signed module for your CPU in `%LOCALAPPDATA%\Programs\camless`: `IntelMSR.bin` on Intel, `AMDFamily17.bin` on AMD Ryzen. Both are in the zip of the latest [PawnIO.Modules release](https://github.com/namazso/PawnIO.Modules/releases/latest). Without them, curves on CPU temperature hold the failsafe duty. When they are missing, the app says so when it starts, with the file this CPU needs, and *Settings → Software from elsewhere* shows what camless found. CPU temperature starts within seconds of putting them in place. The Kraken's liquid temperature needs none of this, so new curves use it by default.
CPU temperature also needs [PawnIO](https://pawnio.eu) and its signed module for your CPU in `C:\Program Files\camless`: `IntelMSR.bin` on Intel, `AMDFamily17.bin` on AMD Ryzen. Both are in the zip of the latest [PawnIO.Modules release](https://github.com/namazso/PawnIO.Modules/releases/latest). Without them, curves on CPU temperature hold the failsafe duty. When they are missing, the app says so when it starts, with the file this CPU needs, and *Settings → Software from elsewhere* shows what camless found. CPU temperature starts within seconds of putting them in place. The Kraken's liquid temperature needs none of this, so new curves use it by default.

GPU temperature, load and power come from NVIDIA's driver (NVML) on an NVIDIA card. Any other card, such as AMD's or Intel's, gives the temperature and load that Task Manager shows, which Windows keeps for every card. An AMD card's power comes from AMD's driver (ADL), from the log the driver keeps, as LibreHardwareMonitor reads it, or else from a reading of the moment; an Intel card has none. If an AMD card shows no power, or power that jumps, `camless report` says which way it was read and what it read over the last minute.

Expand Down
22 changes: 22 additions & 0 deletions core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,15 @@ pub fn xdg_dir(var: &str, fallback: &str) -> PathBuf {
}
}

/// Whether `path` is below the folder `dir`, as Windows compares names: without
/// regard to case, and with either slash. A path that climbs back out with `..` is not.
pub fn is_inside(path: &Path, dir: &Path) -> bool {
let lower = |p: &Path| p.to_string_lossy().to_lowercase().replace('/', "\\");
let (path, dir) = (lower(path), lower(dir));
let dir = dir.trim_end_matches('\\');
!dir.is_empty() && path.strip_prefix(dir).is_some_and(|rest| rest.starts_with('\\') && !rest.contains("\\..\\"))
}

fn split_channel(channel: &str) -> Option<(&str, &str)> {
channel.split_once('/').filter(|(d, c)| !d.is_empty() && !c.is_empty() && !c.contains('/'))
}
Expand Down Expand Up @@ -817,6 +826,19 @@ pub fn curve_order(curves: &[CurveSpec]) -> Result<Vec<usize>> {
mod tests {
use super::*;

#[test]
fn a_path_is_inside_a_folder_the_way_windows_compares() {
let pf = Path::new(r"C:\Program Files");
assert!(is_inside(Path::new(r"C:\Program Files\camless\camless-gui.exe"), pf));
assert!(is_inside(Path::new(r"c:\program files/camless/camless-gui.exe"), Path::new(r"C:\Program Files\")));
// A folder of the user's, a look-alike next to Program Files, and a way back out.
assert!(!is_inside(Path::new(r"C:\Users\A\AppData\Local\Programs\camless\camless-gui.exe"), pf));
assert!(!is_inside(Path::new(r"C:\Program Files Evil\camless-gui.exe"), pf));
assert!(!is_inside(Path::new(r"C:\Program Files\..\Users\A\camless-gui.exe"), pf));
assert!(!is_inside(Path::new(r"C:\Program Files"), pf));
assert!(!is_inside(Path::new(r"C:\x.exe"), Path::new("")));
}

pub const SAMPLE: &str = r#"
interval_ms = 1000
failsafe_duty = 70
Expand Down
31 changes: 24 additions & 7 deletions docs/how-it-works.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ camless is two programs, `camless` and `camless-gui` on [Linux](#linux):

The app starts the service if it is not running. On Windows, it asks for administrator rights (UAC), so CPU temperature works. If the answer is no, the service runs without them and the app says so. The bottom of the sidebar always shows the service's state with a start or restart button, and *Settings → Service* starts, restarts and stops it.

*Settings → Service → Start as administrator without asking* stops the prompts. It is off until you turn it on, and Windows asks once then. The app sets up a scheduled task, `camless (<your user name>)`, that runs `camless-gui.exe --start-service` with your full rights, and from then on starts the service through it, also at logon with *Start with Windows*. The task has no trigger of its own. You may run and delete it without administrator rights, so turning the switch off and uninstalling need none. The trade-off: camless sits in a folder you can write to, so any program you run could replace it and use the task to get administrator rights without a prompt. On a standard account the switch refuses: a task that runs as you could not give the service administrator rights.
*Settings → Service → Start as administrator without asking* stops the prompts. It is off until you turn it on, and Windows asks once then. The app sets up a scheduled task, `camless (<your user name>)`, that runs `camless-gui.exe --start-service` with your full rights, and from then on starts the service through it, also at logon with *Start with Windows*. The task has no trigger of its own. You may run and delete it without administrator rights, so turning the switch off needs none.

A task gives administrator rights to whatever it starts, so camless guards what that is:
- The switch works only for a camless in Program Files, where the setup puts it and only administrators write. A copy elsewhere, such as a build of your own, keeps asking through UAC.
- The task is written by a copy of the app that has administrator rights itself, `camless-gui.exe --set-up-task`, which the switch starts through UAC. It keeps the task's definition in its own folder until Windows has read it.
- The setup writes the task again after every install, for the camless it just installed. If that fails, it deletes the task, and the app asks through UAC again.

On a standard account the switch refuses: a task that runs as you could not give the service administrator rights.

## Software from elsewhere

Expand Down Expand Up @@ -56,15 +63,15 @@ When something this PC needs is missing, the app opens a dialog once each time i
## GPU fans

`[devices] gpu`, off unless you turn it on, lets camless set the graphics card's fans. Experimental: nobody has run it on a card yet. Give them a curve on the GPU's temperature.
- On Windows, NVIDIA cards, through NVML (`nvml.dll`, which comes with the driver): `nvmlDeviceSetFanSpeed_v2` sets a fan's duty, within the card's `nvmlDeviceGetMinMaxFanSpeed`, and `nvmlDeviceSetDefaultFanSpeed_v2` gives it back to the card's curve. The rpm comes from `nvmlDeviceGetFanSpeedRPM`, on drivers that have it. Setting a fan needs administrator rights: without them, or on a card whose fans NVML does not set (`NVML_ERROR_NOT_SUPPORTED`, which no source rules out on GeForce cards), camless says so and leaves the fan out until the service starts again. Before it first sets a fan, camless leaves a file, `%APPDATA%\camless\taken-gpu-fans`: if camless crashes or is killed, the card keeps the last duty until a camless starts again, which gives every fan back to the card's curve, whatever the settings say by then. camless loads `nvml.dll` from System32, or from NVSMI on older drivers, by its full path, for the GPU's sensors too: a service that runs as administrator must not load one from a folder the user's programs can write to. AMD cards on Windows need AMD's ADLX, which camless does not drive yet.
- On Windows, NVIDIA cards, through NVML (`nvml.dll`, which comes with the driver): `nvmlDeviceSetFanSpeed_v2` sets a fan's duty, within the card's `nvmlDeviceGetMinMaxFanSpeed`, and `nvmlDeviceSetDefaultFanSpeed_v2` gives it back to the card's curve. The rpm comes from `nvmlDeviceGetFanSpeedRPM`, on drivers that have it. Setting a fan needs administrator rights: without them, or on a card whose fans NVML does not set (`NVML_ERROR_NOT_SUPPORTED`, which no source rules out on GeForce cards), camless says so and leaves the fan out until the service starts again. Before it first sets a fan, camless leaves a file, `taken-gpu-fans` in [the service's folder](#the-services-own-files): if camless crashes or is killed, the card keeps the last duty until a camless starts again, which gives every fan back to the card's curve, whatever the settings say by then. camless loads `nvml.dll` from System32, or from NVSMI on older drivers, by its full path, for the GPU's sensors too: a service that runs as administrator must not load one from a folder the user's programs can write to. AMD cards on Windows need AMD's ADLX, which camless does not drive yet.
- On Linux, AMD cards, through the `amdgpu` driver's hwmon files, as the motherboard's headers: `pwm1_enable` 1 and `pwm1` for a duty, the mode it had to give it back. The same udev rule gives you those two files. Cards from the RX 7000 series on may not take a duty in `pwm1`: the kernel gives them a fan curve in `gpu_od` instead, which camless does not write. A card that refuses manual mode or the duty is left out once it refuses, until the service starts again. A crash is covered as on the motherboard. NVML needs root on Linux, which the service is not.
- A card's fans are `gpu`, and a second card's `gpu#2`. camless gives a fan back when its curve is removed and when the service stops, the setting goes off, or another program that sets them starts: the motherboard's fan programs and MSI Afterburner.

## History

The service records every sensor, and the speed and duty of every fan, while it runs:
- the last hour at one reading a second, in memory;
- each minute's average and highest value, in `history/` next to `camless.toml`, one CSV file per UTC day. Files older than 30 days are deleted. A day takes about 300 KB with a Kraken and a Control Hub.
- each minute's average and highest value, in `history/` in [the service's folder](#the-services-own-files), one CSV file per UTC day. Files older than 30 days are deleted. A day takes about 300 KB with a Kraken and a Control Hub.

*Monitoring → History* shows them for the last 10 minutes, hour, 24 hours, 7 days or 30 days, a chart for each kind: liquid temperature, CPU and GPU temperature, load, power, fan and pump speeds, and the frame rate while Games is on. Liquid has a chart of its own, scaled close around its readings, so a change of a degree shows; the line at 55 °C, where every fan goes to 100 %, shows once the readings come near it. Each series gives its reading now, its average and its highest over the range. Pointing at a chart shows the readings at that moment, and a line marks it in the others. Dragging across a chart zooms in: sideways on a stretch of time, for every chart, which loads again finer where the history has it; up or down on the values of that chart; far both ways on both. A double-click or *Reset zoom* zooms out. The button in a chart's corner makes it as wide as the page and taller, and the app remembers it. Over 24 hours and more, a point stands for several minutes: the line is their average, and a shade above it shows how high they went. `camless run --demo` keeps its simulated readings in memory only.

Expand Down Expand Up @@ -107,9 +114,11 @@ The safeguards under [Fan control](#fan-control) still apply on top. The server
To add it to Claude Code:

```
claude mcp add camless -- C:\Users\<you>\AppData\Local\Programs\camless\camless.exe mcp
claude mcp add camless -- "C:\Program Files\camless\camless.exe" mcp
```

Until 0.6.0-beta.6 camless was in `%LOCALAPPDATA%\Programs\camless`. An assistant set up with that path needs the new one.

On Linux, the command is `~/.local/bin/camless mcp`.

Or to Claude Desktop, in `claude_desktop_config.json`:
Expand All @@ -118,7 +127,7 @@ Or to Claude Desktop, in `claude_desktop_config.json`:
{
"mcpServers": {
"camless": {
"command": "C:\\Users\\<you>\\AppData\\Local\\Programs\\camless\\camless.exe",
"command": "C:\\Program Files\\camless\\camless.exe",
"args": ["mcp"]
}
}
Expand Down Expand Up @@ -189,9 +198,17 @@ The fonts are in `gui/ui`: Archivo for text, Saira for digits, and one glyph fro

## Installs and updates

`camless-setup.exe` (Inno Setup, `installer/camless.iss`) installs both exes for the current user in `%LOCALAPPDATA%\Programs\camless`. Run over an installed camless, it closes the app, stops the service through `POST /v1/stop`, replaces both exes and opens the app again, which starts the service.
`camless-setup.exe` (Inno Setup, `installer/camless.iss`) installs both exes in `C:\Program Files\camless` and asks Windows for administrator rights to do it. The service runs as administrator, so its program must be where only administrators write: in a folder of yours, any program you run could replace it. Run over an installed camless, the setup closes the app, stops the service through `POST /v1/stop`, replaces both exes and opens the app again, without the setup's rights. The app starts the service.

Until 0.6.0-beta.6 the setup needed no administrator rights and put camless in `%LOCALAPPDATA%\Programs\camless`. The setup moves such a copy: it removes the old exes, uninstaller, shortcuts and entry in Windows' list of apps, takes a PawnIO module along, and writes the task for *Start as administrator without asking* again. It runs nothing from the old folder, and it deletes there with your rights, not its own: the folder is yours, and a link in its place could lead anywhere. It leaves a folder that is a link alone. The app points *Start with Windows* at its new place when it starts. A `camless.toml` that you put beside the old exe stays there with its `profiles`, and camless goes back to the one in `%APPDATA%\camless`: move them there to keep those settings. This happens for the account that answers the UAC prompt. If you install with another account's administrator password, uninstall the old copy yourself in *Settings → Apps*.

The app asks GitHub for the latest release once each time it starts. *Update* downloads `camless-setup.exe`, checks it against the release's SHA-256, quits the app and runs the setup, so the app and the service always update together. Uninstalling keeps `%APPDATA%\camless` and the history unless you choose to delete them.

### The service's own files

The service writes three things: the history, the game sessions (`history/sessions.jsonl`) and `taken-gpu-fans`. The history and the sessions are in the folder of `camless.toml`. `taken-gpu-fans` is in `%APPDATA%\camless` whatever config the service runs, so that the next camless finds it. There is one exception: the installed service on Windows, while it runs as administrator, keeps all three in `C:\Program Files\camless\data`. In a folder of yours, a program you run could put a link in place of `history`, and the service would write wherever the link leads, with administrator rights.

The app asks GitHub for the latest release once each time it starts. *Update* downloads `camless-setup.exe`, checks it against the release's SHA-256, quits the app and runs the setup, so the app and the service always update together. Uninstalling keeps `%APPDATA%\camless` unless you choose to delete it.
The first time it uses that folder, the service brings over the history beside `camless.toml`, all of it or none: a service that stops halfway starts again the next time. It takes day files and `sessions.jsonl` only, and of those only the lines that are history or sessions. The old files stay. A service that runs without administrator rights writes beside `camless.toml` as before, so the two do not see each other's days.

*Settings → About → Update channel* picks what the app offers:
- **Stable**, the default, offers releases.
Expand Down
1 change: 1 addition & 0 deletions gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ windows-sys = { version = "0.61", features = [
"Win32_Security_Authorization",
"Win32_Security_Cryptography",
"Win32_System_Registry",
"Win32_System_SystemInformation",
"Win32_System_Threading",
"Win32_System_WindowsProgramming",
"Win32_UI_Shell",
Expand Down
7 changes: 6 additions & 1 deletion gui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
//!
//! `camless-gui --serve 127.0.0.1:<port> --config <camless.toml> [--ui-dir <dir>]`
//! serves the same page to a browser instead, as a sandbox, to work on the UI.
//! `camless-gui --start-service` starts the service and exits; see [`task`].
//! `camless-gui --start-service` starts the service and exits, and `--set-up-task`
//! sets up the task that runs it; see [`task`].
//!
//! On Linux the window is GTK's and the page WebKitGTK's ([`app`]), the tray icon an
//! AppIndicator ([`tray`]), and the service a systemd user service ([`service`]).
Expand Down Expand Up @@ -41,6 +42,10 @@ fn main() -> anyhow::Result<()> {
if args.iter().any(|a| a == task::START_SERVICE) {
return client::start_daemon(&camless_core::config::default_path());
}
#[cfg(windows)]
if args.iter().any(|a| a == task::SET_UP) {
return task::set_up_elevated();
}
if let Some(listen) = value("--serve") {
let config = value("--config")
.map(PathBuf::from)
Expand Down
Loading