Skip to content

Commit b6d32e0

Browse files
committed
chore: Update sensors_librehardwaremonitor.py and stats.py files
1 parent 2a25630 commit b6d32e0

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

library/sensors/sensors_librehardwaremonitor.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,23 @@ def stats(cls) -> Tuple[float, float, float, float]: # load (%) / used mem (%)
296296

297297
return load, (used_mem / total_mem * 100.0), used_mem, temp
298298

299+
@classmethod
300+
def total_memory(cls) -> float:
301+
gpu_to_use = get_hw_and_update(Hardware.HardwareType.GpuAmd, cls.gpu_name)
302+
if gpu_to_use is None:
303+
gpu_to_use = get_hw_and_update(Hardware.HardwareType.GpuNvidia, cls.gpu_name)
304+
if gpu_to_use is None:
305+
gpu_to_use = get_hw_and_update(Hardware.HardwareType.GpuIntel, cls.gpu_name)
306+
if gpu_to_use is None:
307+
# GPU not supported
308+
return math.nan
309+
310+
for sensor in gpu_to_use.Sensors:
311+
if sensor.SensorType == Hardware.SensorType.SmallData and str(sensor.Name).startswith("GPU Memory Total"):
312+
return float(sensor.Value)
313+
314+
return math.nan
315+
299316
@classmethod
300317
def fps(cls) -> int:
301318
gpu_to_use = cls.get_gpu_to_use()

library/stats.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ def stats(cls):
359359
fps = sensors.Gpu.fps()
360360
fan_percent = sensors.Gpu.fan_percent()
361361
freq_ghz = sensors.Gpu.frequency() / 1000
362+
total_memory = sensors.Gpu.total_memory()
362363

363364
theme_gpu_data = config.THEME_DATA['STATS']['GPU']
364365

@@ -458,6 +459,16 @@ def stats(cls):
458459
unit=" M"
459460
)
460461

462+
# GPU mem. total memory (M)
463+
gpu_total_mem_text_data = theme_gpu_data['MEMORY_TOTAL']['TEXT']
464+
if gpu_total_mem_text_data and gpu_total_mem_text_data['SHOW']:
465+
display_themed_value(
466+
theme_data=gpu_total_mem_text_data,
467+
value=int(total_memory),
468+
min_size=5, # Adjust min_size as necessary for your display
469+
unit=" M" # Assuming the unit is in Megabytes
470+
)
471+
461472
# GPU temperature (°C)
462473
gpu_temp_text_data = theme_gpu_data['TEMPERATURE']['TEXT']
463474
gpu_temp_radial_data = theme_gpu_data['TEMPERATURE']['RADIAL']

0 commit comments

Comments
 (0)