GPU Temp: Added voluntary opt-in for Nvidia GPU - avoid draining battery on dual gpus laptop.

This commit is contained in:
Lemmy
2025-12-14 12:08:08 -05:00
parent 2cbe4f90bd
commit 5f18e4b6d0
5 changed files with 54 additions and 7 deletions
+39 -7
View File
@@ -50,7 +50,8 @@ Singleton {
// GPU temperature detection
// On dual-GPU systems, we prioritize discrete GPUs over integrated GPUs
// Priority: NVIDIA > AMD dGPU > Intel Arc > AMD iGPU
// Priority: NVIDIA (opt-in) > AMD dGPU > Intel Arc > AMD iGPU
// Note: NVIDIA requires opt-in because nvidia-smi wakes the dGPU on laptops, draining battery
readonly property var supportedTempGpuSensorNames: ["amdgpu", "xe"]
property string gpuTempHwmonPath: ""
property var foundGpuSensors: [] // [{hwmonPath, type, hasDedicatedVram}]
@@ -67,6 +68,29 @@ Singleton {
gpuTempNameReader.checkNext();
}
// Re-run GPU detection when NVIDIA opt-in setting changes
Connections {
target: Settings.data.systemMonitor
function onEnableNvidiaGpuChanged() {
Logger.i("SystemStat", "NVIDIA opt-in setting changed, re-detecting GPUs");
restartGpuDetection();
}
}
function restartGpuDetection() {
// Reset GPU state
root.gpuAvailable = false;
root.gpuType = "";
root.gpuTempHwmonPath = "";
root.gpuTemp = 0;
root.foundGpuSensors = [];
root.gpuVramCheckIndex = 0;
// Restart GPU detection
gpuTempNameReader.currentIndex = 0;
gpuTempNameReader.checkNext();
}
// --------------------------------------------
// Timer for CPU usage
Timer {
@@ -295,9 +319,17 @@ Singleton {
function checkNext() {
if (currentIndex >= 16) {
// Finished scanning all hwmon entries, now check for NVIDIA
Logger.d("SystemStat", `Found ${root.foundGpuSensors.length} sysfs GPU sensor(s), checking for nvidia-smi`);
nvidiaSmiCheck.running = true;
// Finished scanning all hwmon entries
// Only check nvidia-smi if user has explicitly enabled NVIDIA monitoring (opt-in)
// because nvidia-smi wakes up the dGPU on laptops, draining battery
if (Settings.data.systemMonitor.enableNvidiaGpu) {
Logger.d("SystemStat", `Found ${root.foundGpuSensors.length} sysfs GPU sensor(s), checking nvidia-smi (opt-in enabled)`);
nvidiaSmiCheck.running = true;
} else {
Logger.d("SystemStat", `Found ${root.foundGpuSensors.length} sysfs GPU sensor(s), skipping nvidia-smi (opt-in disabled)`);
root.gpuVramCheckIndex = 0;
checkNextGpuVram();
}
return;
}
@@ -698,9 +730,9 @@ Singleton {
// -------------------------------------------------------
// Function to update GPU temperature
function updateGpuTemperature() {
if (root.gpuType === "nvidia")
//nvidiaTempProcess.running = true;
{} else if (root.gpuType === "amd" || root.gpuType === "intel") {
if (root.gpuType === "nvidia") {
nvidiaTempProcess.running = true;
} else if (root.gpuType === "amd" || root.gpuType === "intel") {
gpuTempReader.path = `${root.gpuTempHwmonPath}/temp1_input`;
gpuTempReader.reload();
}