Skip to content

Commit dbdf154

Browse files
authored
Merge pull request #485 from majormer/main
2 parents 74fa90f + 0e32264 commit dbdf154

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

library/sensors/sensors_librehardwaremonitor.py

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

313313
return load, (used_mem / total_mem * 100.0), used_mem, temp
314314

315+
@classmethod
316+
def total_memory(cls) -> float:
317+
gpu_to_use = get_hw_and_update(Hardware.HardwareType.GpuAmd, cls.gpu_name)
318+
if gpu_to_use is None:
319+
gpu_to_use = get_hw_and_update(Hardware.HardwareType.GpuNvidia, cls.gpu_name)
320+
if gpu_to_use is None:
321+
gpu_to_use = get_hw_and_update(Hardware.HardwareType.GpuIntel, cls.gpu_name)
322+
if gpu_to_use is None:
323+
# GPU not supported
324+
return math.nan
325+
326+
for sensor in gpu_to_use.Sensors:
327+
if sensor.SensorType == Hardware.SensorType.SmallData and str(sensor.Name).startswith("GPU Memory Total"):
328+
return float(sensor.Value)
329+
330+
return math.nan
331+
315332
@classmethod
316333
def fps(cls) -> int:
317334
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
@@ -371,6 +371,7 @@ def stats(cls):
371371
fps = sensors.Gpu.fps()
372372
fan_percent = sensors.Gpu.fan_percent()
373373
freq_ghz = sensors.Gpu.frequency() / 1000
374+
total_memory = sensors.Gpu.total_memory()
374375

375376
theme_gpu_data = config.THEME_DATA['STATS']['GPU']
376377

@@ -470,6 +471,16 @@ def stats(cls):
470471
unit=" M"
471472
)
472473

474+
# GPU mem. total memory (M)
475+
gpu_total_mem_text_data = theme_gpu_data['MEMORY_TOTAL']['TEXT']
476+
if gpu_total_mem_text_data and gpu_total_mem_text_data['SHOW']:
477+
display_themed_value(
478+
theme_data=gpu_total_mem_text_data,
479+
value=int(total_memory),
480+
min_size=5, # Adjust min_size as necessary for your display
481+
unit=" M" # Assuming the unit is in Megabytes
482+
)
483+
473484
# GPU temperature (°C)
474485
gpu_temp_text_data = theme_gpu_data['TEMPERATURE']['TEXT']
475486
gpu_temp_radial_data = theme_gpu_data['TEMPERATURE']['RADIAL']

res/themes/default.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ STATS:
7676
MEMORY_USED:
7777
TEXT:
7878
SHOW: False
79-
MEMORY: # Deprecated, do not use
79+
MEMORY_TOTAL:
80+
TEXT:
81+
SHOW: False
82+
MEMORY: # Deprecated, do not use
8083
GRAPH:
8184
SHOW: False
8285
RADIAL:

0 commit comments

Comments
 (0)