Skip to content

Commit 57842ed

Browse files
authored
Switch to using most active gpu in statusbar and indicator (#504)
patch: switch to using most active gpu in statusbar
1 parent 6c51160 commit 57842ed

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/Resources/Resources.vala

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,13 @@ public class Monitor.Resources : Object {
9595

9696
// quick fix; so no need to comment out GPU
9797
// code for Indicator and Preferences
98-
IGPU gpu = gpu_list.size > 0 ? gpu_list.first () : null;
98+
IGPU active_gpu = gpu_list.size > 0 ? gpu_list.first () : null;
99+
100+
foreach (IGPU gpu in gpu_list) {
101+
if (gpu.percentage > active_gpu.percentage) {
102+
active_gpu = gpu;
103+
}
104+
}
99105

100106
return ResourcesSerialized () {
101107
cpu_percentage = cpu.percentage,
@@ -109,11 +115,11 @@ public class Monitor.Resources : Object {
109115
swap_total = swap.total,
110116
network_up = network.bytes_out,
111117
network_down = network.bytes_in,
112-
gpu_percentage = gpu != null ? gpu.percentage : 0,
113-
gpu_memory_percentage = gpu != null ? gpu.memory_percentage : 0,
114-
gpu_memory_used = gpu != null ? gpu.memory_vram_used : 0,
115-
gpu_memory_total = gpu != null ? gpu.memory_vram_total : 0,
116-
gpu_temperature = gpu != null ? gpu.temperature : 0
118+
gpu_percentage = active_gpu != null ? active_gpu.percentage : 0,
119+
gpu_memory_percentage = active_gpu != null ? active_gpu.memory_percentage : 0,
120+
gpu_memory_used = active_gpu != null ? active_gpu.memory_vram_used : 0,
121+
gpu_memory_total = active_gpu != null ? active_gpu.memory_vram_total : 0,
122+
gpu_temperature = active_gpu != null ? active_gpu.temperature : 0
117123
};
118124
}
119125

0 commit comments

Comments
 (0)