The last two values that could only be changed by editing a file. Weather was pinned to hardcoded coordinates, so the card could not be pointed anywhere else. It is a location search now, not latitude and longitude fields: nobody knows their own coordinates, and a control that demands them is one nobody uses. Open-Meteo's geocoding endpoint needs no key, the same reason the forecast already uses them. Only the search term leaves the machine -- the stored place name is a label -- and coordinates are rounded to four decimals, far finer than a weather reading resolves and coarse enough to keep a precise home location out of the settings file. The graphics readout was hardcoded to card1. This machine has two amdgpu cards, discrete and integrated, so that was right only by luck, and the path is meaningless on any other machine. GPUs are enumerated with a readable name from lspci, since sysfs exposes only numeric ids, and the picker appears only when there is more than one to choose between. A stored path the machine does not have is refused and reported rather than silently measuring nothing. Also merges the per-application notification rules UI. Its three commits were believed integrated but the page half was not actually in the tree: main had the service side in Notifs.qml and zero references to setAppRule in NotificationsPage. Ancestry is not content. Claude-Session: https://claude.ai/code/session_01BRvzt4H8XXLPVH5MyYdk9L
88 lines
2.6 KiB
JavaScript
88 lines
2.6 KiB
JavaScript
function clamp(value, minimum, maximum) {
|
|
return Math.max(minimum, Math.min(maximum, value));
|
|
}
|
|
|
|
function finiteNumber(value, fallback) {
|
|
var parsed = Number(value);
|
|
return isFinite(parsed) ? parsed : fallback;
|
|
}
|
|
|
|
function iconFor(kind, ratio) {
|
|
var name = String(kind || "").toLowerCase();
|
|
if (name === "volume-muted")
|
|
return "audio-volume-muted-symbolic";
|
|
if (name === "volume") {
|
|
if (ratio <= 0)
|
|
return "audio-volume-muted-symbolic";
|
|
if (ratio < 0.34)
|
|
return "audio-volume-low-symbolic";
|
|
if (ratio < 0.67)
|
|
return "audio-volume-medium-symbolic";
|
|
return "audio-volume-high-symbolic";
|
|
}
|
|
if (name === "microphone-muted")
|
|
return "microphone-sensitivity-muted-symbolic";
|
|
if (name === "microphone")
|
|
return "audio-input-microphone-symbolic";
|
|
if (name === "brightness")
|
|
return "display-brightness-symbolic";
|
|
if (name === "media-play" || name === "media-playing")
|
|
return "media-playback-start-symbolic";
|
|
if (name === "media-pause" || name === "media-paused")
|
|
return "media-playback-pause-symbolic";
|
|
if (name === "media-next")
|
|
return "media-skip-forward-symbolic";
|
|
if (name === "media-previous")
|
|
return "media-skip-backward-symbolic";
|
|
if (name === "media-stop")
|
|
return "media-playback-stop-symbolic";
|
|
return name || "dialog-information-symbolic";
|
|
}
|
|
|
|
function normalizedDuration(value) {
|
|
var parsed = finiteNumber(value, 1400);
|
|
return Math.max(0, Math.round(parsed));
|
|
}
|
|
|
|
function progressState(kind, rawValue, rawMaximum, rawLabel, rawDuration) {
|
|
var maximum = Math.max(1, finiteNumber(rawMaximum, 100));
|
|
var value = clamp(finiteNumber(rawValue, 0), 0, maximum);
|
|
var ratio = value / maximum;
|
|
var label = String(rawLabel || "");
|
|
if (!label)
|
|
label = Math.round(ratio * 100) + "%";
|
|
|
|
return {
|
|
kind: String(kind || ""),
|
|
value: value,
|
|
maximum: maximum,
|
|
ratio: ratio,
|
|
label: label,
|
|
icon: iconFor(kind, ratio),
|
|
duration: normalizedDuration(rawDuration),
|
|
progress: true
|
|
};
|
|
}
|
|
|
|
function messageState(kind, rawLabel, rawDuration) {
|
|
return {
|
|
kind: String(kind || ""),
|
|
value: 0,
|
|
maximum: 100,
|
|
ratio: 0,
|
|
label: String(rawLabel || ""),
|
|
icon: iconFor(kind, 0),
|
|
duration: normalizedDuration(rawDuration),
|
|
progress: false
|
|
};
|
|
}
|
|
|
|
if (typeof module !== "undefined") {
|
|
module.exports = {
|
|
clamp: clamp,
|
|
iconFor: iconFor,
|
|
progressState: progressState,
|
|
messageState: messageState
|
|
};
|
|
}
|