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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. 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 `%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.

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
33 changes: 33 additions & 0 deletions core/src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,39 @@ pub struct ServiceInfo {
/// Why games have no frame rates, when they have none.
#[serde(default)]
pub fps_error: Option<String>,
/// Software camless uses that Windows or the Linux desktop may not come with,
/// and whether this PC has it.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub requirements: Vec<Requirement>,
}

/// A program or file camless needs from elsewhere for one thing it does.
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
pub struct Requirement {
/// Stable, for the app to remember that it asked about it: `pawnio`.
pub id: String,
pub name: String,
/// What camless does with it: "CPU temperature and power".
pub used_for: String,
/// What camless found that needs it, such as the CPU's maker; none when nothing
/// on this PC needs it now.
pub needed_because: Option<String>,
pub installed: bool,
/// How to get it, in a sentence or two.
pub how: String,
/// A page the app opens for it, by a name the app knows: `pawnio`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub link: Option<String>,
/// The file goes in camless's own folder, which the app can open.
#[serde(default)]
pub in_app_folder: bool,
}

impl Requirement {
/// Needed on this PC, and not there.
pub fn missing(&self) -> bool {
self.needed_because.is_some() && !self.installed
}
}

/// One way of reading the GPU's power, and what it read over the last minute.
Expand Down
10 changes: 10 additions & 0 deletions docs/how-it-works.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ The app starts the service if it is not running. On Windows, it asks for adminis

*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.

## Software from elsewhere

Some of what camless does needs software that Windows or a Linux desktop may not come with. The service checks for it every 5 seconds and lists it in its status. *Settings → Software from elsewhere* shows each one, what it is for, and whether this PC needs and has it:
- **PawnIO**, on Windows: the driver that lets a program read the CPU's sensors. FanControl and LibreHardwareMonitor install the same one. Found at `C:\Program Files\PawnIO\PawnIOLib.dll`.
- **`IntelMSR.bin` or `AMDFamily17.bin`**, on Windows: PawnIO's signed module for this CPU's maker, which the service reads from its own folder (or `pawnio_module` in `camless.toml`). The CPU's maker comes from the registry, so the app says which file this PC needs.
- **A Chromium browser**, needed only while an LCD shows a [web page](#web-pages-on-the-lcd).
- **curl**, on Linux, for [updates](#installs-and-updates). The app checks this one itself.

When something this PC needs is missing, the app opens a dialog once each time it starts, with what camless found that needs it and how to get it. *Don't ask again* stops the dialog for that item; Settings still lists it. When CPU temperature is off and the list changes, the service tries PawnIO again every 5 seconds for 30 seconds, while the setup starts the driver, so CPU temperature starts once PawnIO and its module are in place, without a restart. Administrator rights are still needed on top. `camless report` names what is missing, without the folders.

## Fan control

- **Curves a device can run by itself are stored on it.** This means a fixed duty, or a graph on the device's own sensor (a Kraken's liquid temperature). The Kraken keeps running them if camless stops. The fan's offset and limits are folded in. Smoothing and hysteresis are host-only.
Expand Down
41 changes: 36 additions & 5 deletions gui/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl Backend {
("POST", "update/check") => update::check(update::channel(&self.path())).map(|_| json!({})).map_err(Refused::from),
("POST", "update/install") => self.install_update(),
("POST", "update/notes") => self.release_notes(),
("POST", "open-folder") => self.open_folder(),
("POST", "open-folder") => self.open_folder(body),
("POST", "report") => report::start(&self.path()).map(|_| json!(report::state())).map_err(Refused::from),
("GET", "report") => Ok(json!(report::state())),
("POST", "report/issue") => self.report_issue(body),
Expand Down Expand Up @@ -212,6 +212,8 @@ impl Backend {
"admin_task_error": task.error,
"update": update::state(),
"sandbox": self.sandbox,
// The service lists what it needs; these are the app's own.
"requirements": app_requirements(),
})
}

Expand Down Expand Up @@ -447,20 +449,41 @@ impl Backend {
Ok(json!({}))
}

fn open_folder(&self) -> Answer {
/// The config's folder, or with `{"app": true}` camless's own, where PawnIO's
/// module goes.
fn open_folder(&self, body: &[u8]) -> Answer {
#[derive(Deserialize)]
struct Which {
#[serde(default)]
app: bool,
}
let Which { app } = parse(body)?;
if self.sandbox {
bail_refused("the sandbox does not open Explorer")?;
}
let path = self.path();
let dir = path.parent().filter(|d| d.exists()).ok_or_else(|| anyhow!("{} has no folder yet", path.display()))?;
let dir = if app {
let exe = std::env::current_exe().context("finding camless's folder")?;
exe.parent().map(Path::to_path_buf).ok_or_else(|| anyhow!("{} has no folder", exe.display()))?
} else {
let path = self.path();
path.parent().filter(|d| d.exists()).map(Path::to_path_buf).ok_or_else(|| anyhow!("{} has no folder yet", path.display()))?
};
#[cfg(windows)]
std::process::Command::new("explorer.exe").arg(dir).spawn().context("starting Explorer")?;
std::process::Command::new("explorer.exe").arg(&dir).spawn().context("starting Explorer")?;
#[cfg(not(windows))]
report::open_url(&dir.to_string_lossy())?;
Ok(json!({}))
}
}

/// What the app itself needs from elsewhere: curl for updates, on Linux.
fn app_requirements() -> Vec<camless_core::status::Requirement> {
#[cfg(target_os = "linux")]
return vec![crate::http::requirement()];
#[cfg(not(target_os = "linux"))]
Vec::new()
}

#[derive(Deserialize)]
struct Name {
name: String,
Expand All @@ -470,6 +493,9 @@ struct Name {
fn link(name: &str) -> Option<&'static str> {
Some(match name {
"krakendial" => "https://github.com/kleju13/krakendial",
// What the service lists as missing names these.
"pawnio" => "https://pawnio.eu",
"pawnio-modules" => "https://github.com/namazso/PawnIO.Modules/releases/latest",
_ => return None,
})
}
Expand Down Expand Up @@ -658,6 +684,11 @@ mod tests {
let (b, _) = fixture("camless-gui-links");
assert_eq!(call(&b, "POST", "/api/open-link", json!({ "name": "https://example.com" })).0, 400);
assert_eq!(call(&b, "POST", "/api/open-link", json!({ "name": "krakendial" })).0, 409, "the sandbox opens no browser");
// src/requirements.rs links to these.
for name in ["pawnio", "pawnio-modules"] {
assert!(link(name).is_some_and(|u| u.starts_with("https://")), "{name}");
}
assert_eq!(call(&b, "POST", "/api/open-folder", json!({ "app": true })).0, 409, "the sandbox opens no folder");
}

#[test]
Expand Down
15 changes: 15 additions & 0 deletions gui/src/http_curl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ const AGENT: &str = concat!("camless/", env!("CARGO_PKG_VERSION"));
/// Larger answers are not a release of camless.
const MAX_BODY: usize = 64 << 20;

/// curl, which not every desktop comes with, and whether it is on the PATH.
pub fn requirement() -> camless_core::status::Requirement {
let installed = std::env::var_os("PATH").is_some_and(|p| std::env::split_paths(&p).any(|d| d.join("curl").is_file()));
camless_core::status::Requirement {
id: "curl".into(),
name: "curl".into(),
used_for: "Updates".into(),
needed_because: Some("The app checks GitHub for a new camless and downloads it with curl".into()),
installed,
how: "Install the curl package from your distribution, such as sudo apt install curl.".into(),
link: None,
in_app_folder: false,
}
}

/// The body of `url`, which must be https, if it answers 200.
pub fn get(url: &str) -> Result<Vec<u8>> {
let rest = url.strip_prefix("https://").with_context(|| format!("{url} is not an https URL"))?;
Expand Down
1 change: 1 addition & 0 deletions gui/ui/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ body.light { background: #f7f6fa; }
.cam-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--t3); }
.cam-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.cam-status.off::before { background: var(--t4); }
.cam-status.warn::before { background: var(--amber); }

.cam-alert { position: sticky; top: 0; z-index: 5; display: flex; align-items: flex-start; gap: 10px; margin: 0 0 14px; padding: 9px 12px; border-radius: var(--radius); background: var(--alert-bg); border: 1px solid rgba(255, 2, 45, .45); color: var(--t1); font-size: 13px; backdrop-filter: blur(10px); }
.cam-alert svg.i { color: var(--alert); width: 18px; height: 18px; margin-top: 1px; }
Expand Down
86 changes: 86 additions & 0 deletions gui/ui/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@
nav.appendChild(serviceBadge());
nav.appendChild(updateBadge());
nav.appendChild(verifyBadge());
S.on('state', askRequirements);
const navItems = () => nav.querySelectorAll('a[data-id]').forEach((a) => { a.hidden = !navShown(a.dataset.id); });
S.on('config', navItems);
navItems();
Expand Down Expand Up @@ -427,6 +428,90 @@
return el;
}

/* Software from elsewhere that camless needs: PawnIO and the module for this CPU for
CPU temperature on Windows, a browser for web pages on the LCD, curl for updates on
Linux. The service lists its own and checks again every few seconds; the app adds
what it needs itself. */
const requirements = () => [].concat((S.status && S.status.service && S.status.service.requirements) || [], (S.server && S.server.requirements) || []);
const missing = (r) => !!r.needed_because && !r.installed;
const askKey = (r) => `${r.id}:${r.name}`;
const lowerFirst = (t) => (/^[A-Z][a-z]/.test(t) ? t[0].toLowerCase() + t.slice(1) : t);
let askedRequirements = false;

function requirementStatus(r) {
const [text, tone] = r.installed ? ['Installed', ''] : r.needed_because ? ['Missing', ' warn'] : ['Not installed', ' off'];
return h(`<span class="cam-status${tone}">${text}</span>`);
}

// Get it opens the page the service names, through the app's own list of links.
function requirementButtons(r) {
const out = [];
if (r.installed) return out;
if (r.link) out.push(button('Get it', { small: true, onClick: () => act('open-link', { name: r.link }) }));
if (r.in_app_folder && !S.server.sandbox) out.push(button('Open folder', { small: true, onClick: () => act('open-folder', { app: true }) }));
return out;
}

function requirementHint(r) {
const why = r.needed_because ? `${esc(sentence(r.needed_because))}` : 'Nothing on this PC needs it now.';
return `For ${esc(lowerFirst(r.used_for))}. ${why}${r.installed ? '' : ` ${esc(r.how)}`}`;
}

const cpuNote = (list) => (list.some((r) => r.id.startsWith('pawnio'))
? `Until then, curves on CPU temperature hold the failsafe speed, ${failsafe()}%. The Kraken’s liquid temperature needs none of this. camless looks again every few seconds and starts reading the CPU once everything is in place, without a restart.`
: 'camless looks again every few seconds, so there is nothing to restart.');

// Once each time the app starts, while something this PC needs is missing, unless the
// person said not to ask about it again.
function requirementsDialog(list) {
modal({
title: list.length > 1 ? 'camless needs software from elsewhere' : `camless needs ${list[0].name}`,
render(body) {
body.appendChild(h(`<p class="cam-lead"><b>camless found something on this PC that needs ${list.length > 1 ? 'these, and they are' : 'this, and it is'} not installed.</b></p>`));
const rows = h('<div class="cam-rows cam-box"></div>');
for (const r of list) rows.appendChild(row(r.name, requirementHint(r), requirementButtons(r)));
body.appendChild(rows);
body.appendChild(Object.assign(h('<p class="cam-hint"></p>'), { textContent: `${cpuNote(list)} Settings lists all of it under Software from elsewhere.` }));
},
actions: [
{ label: 'Don’t ask again', onClick: () => { K.setPref('requirementsAsked', [...new Set([...(K.prefs.requirementsAsked || []), ...list.map(askKey)])]); toast('camless will not ask about it again. Settings still lists it.'); } },
{ label: 'Later', primary: true },
],
});
}

// Only once the service answers, so the dialog has the whole list.
function askRequirements() {
if (askedRequirements || !S.status || busy()) return;
const done = K.prefs.requirementsAsked || [];
const list = requirements().filter((r) => missing(r) && !done.includes(askKey(r)));
if (!list.length) return;
askedRequirements = true;
requirementsDialog(list);
}

// The Settings panel: every program and file camless uses from elsewhere, read again
// with each state.
function requirementsPanel(host) {
const s = K.section(host, 'Software from elsewhere');
const p = h('<div class="cam-panel cam-rows"></div>');
s.appendChild(p);
s.appendChild(Object.assign(h('<p class="cam-hint cam-under"></p>'), { textContent: 'What camless uses that Windows or a Linux desktop may not come with. camless looks again every few seconds.' }));
let key = null;
const upd = () => {
const list = requirements();
const k = JSON.stringify([list, !!S.status]);
if (k === key) return;
key = k;
p.replaceChildren();
for (const r of list) p.appendChild(row(r.name, requirementHint(r), [...requirementButtons(r), requirementStatus(r)]));
if (!S.status) p.appendChild(row('The service is not running', 'Start it to see what it needs, such as PawnIO for CPU temperature on Windows.', null));
};
track(S.on('state', upd));
upd();
return s;
}

function go() {
built = layoutKey();
let id = decodeURIComponent(location.hash.slice(1)) || K.prefs.page || 'cooling';
Expand Down Expand Up @@ -3566,6 +3651,7 @@
track(S.on('state', () => { if (!autoT.dataset.busy) autoT.set(S.server.autostart); autoRow.hint(autoHint()); }));

panel('Service', [serviceRow(), autoRow, linux() ? null : adminRow()]);
requirementsPanel(host);

const general = panel('General', [
row('Temperature display', null, choice({ options: [{ value: 'c', label: 'Celsius' }, { value: 'f', label: 'Fahrenheit' }], value: K.prefs.unit, label: 'Temperature display', onChange: (v) => K.setPref('unit', v) })),
Expand Down
Loading