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
+4
View File
@@ -2088,6 +2088,10 @@
"gpu-section": {
"label": "GPU temperature"
},
"enable-nvidia-gpu": {
"label": "Enable NVIDIA GPU monitoring",
"description": "Warning: This will wake up your NVIDIA GPU, which may significantly impact battery life on laptops with hybrid graphics."
},
"highlight-colors-section": {
"label": "Highlight colors"
},
+1
View File
@@ -248,6 +248,7 @@
"cpuPollingInterval": 3000,
"tempPollingInterval": 3000,
"gpuPollingInterval": 3000,
"enableNvidiaGpu": false,
"memPollingInterval": 3000,
"diskPollingInterval": 3000,
"networkPollingInterval": 3000,
+1
View File
@@ -434,6 +434,7 @@ Singleton {
property int cpuPollingInterval: 3000
property int tempPollingInterval: 3000
property int gpuPollingInterval: 3000
property bool enableNvidiaGpu: false // Opt-in: nvidia-smi wakes dGPU on laptops, draining battery
property int memPollingInterval: 3000
property int diskPollingInterval: 3000
property int networkPollingInterval: 3000
@@ -18,6 +18,15 @@ ColumnLayout {
description: I18n.tr("settings.system-monitor.general.section.description")
}
NToggle {
Layout.fillWidth: true
Layout.topMargin: Style.marginM
label: I18n.tr("settings.system-monitor.enable-nvidia-gpu.label")
description: I18n.tr("settings.system-monitor.enable-nvidia-gpu.description")
checked: Settings.data.systemMonitor.enableNvidiaGpu
onToggled: checked => Settings.data.systemMonitor.enableNvidiaGpu = checked
}
// Colors Section
RowLayout {
Layout.fillWidth: true
+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();
}