diff --git a/library/sensors/sensors_librehardwaremonitor.py b/library/sensors/sensors_librehardwaremonitor.py index 7f95df11..098d0f2c 100644 --- a/library/sensors/sensors_librehardwaremonitor.py +++ b/library/sensors/sensors_librehardwaremonitor.py @@ -312,6 +312,23 @@ def stats(cls) -> Tuple[float, float, float, float]: # load (%) / used mem (%) return load, (used_mem / total_mem * 100.0), used_mem, temp + @classmethod + def total_memory(cls) -> float: + gpu_to_use = get_hw_and_update(Hardware.HardwareType.GpuAmd, cls.gpu_name) + if gpu_to_use is None: + gpu_to_use = get_hw_and_update(Hardware.HardwareType.GpuNvidia, cls.gpu_name) + if gpu_to_use is None: + gpu_to_use = get_hw_and_update(Hardware.HardwareType.GpuIntel, cls.gpu_name) + if gpu_to_use is None: + # GPU not supported + return math.nan + + for sensor in gpu_to_use.Sensors: + if sensor.SensorType == Hardware.SensorType.SmallData and str(sensor.Name).startswith("GPU Memory Total"): + return float(sensor.Value) + + return math.nan + @classmethod def fps(cls) -> int: gpu_to_use = cls.get_gpu_to_use() diff --git a/library/stats.py b/library/stats.py index 1afa9fe6..31dbdbdc 100644 --- a/library/stats.py +++ b/library/stats.py @@ -371,6 +371,7 @@ def stats(cls): fps = sensors.Gpu.fps() fan_percent = sensors.Gpu.fan_percent() freq_ghz = sensors.Gpu.frequency() / 1000 + total_memory = sensors.Gpu.total_memory() theme_gpu_data = config.THEME_DATA['STATS']['GPU'] @@ -470,6 +471,16 @@ def stats(cls): unit=" M" ) + # GPU mem. total memory (M) + gpu_total_mem_text_data = theme_gpu_data['MEMORY_TOTAL']['TEXT'] + if gpu_total_mem_text_data and gpu_total_mem_text_data['SHOW']: + display_themed_value( + theme_data=gpu_total_mem_text_data, + value=int(total_memory), + min_size=5, # Adjust min_size as necessary for your display + unit=" M" # Assuming the unit is in Megabytes + ) + # GPU temperature (°C) gpu_temp_text_data = theme_gpu_data['TEMPERATURE']['TEXT'] gpu_temp_radial_data = theme_gpu_data['TEMPERATURE']['RADIAL'] diff --git a/res/themes/default.yaml b/res/themes/default.yaml index 28b1f186..6528d7db 100644 --- a/res/themes/default.yaml +++ b/res/themes/default.yaml @@ -76,7 +76,10 @@ STATS: MEMORY_USED: TEXT: SHOW: False - MEMORY: # Deprecated, do not use + MEMORY_TOTAL: + TEXT: + SHOW: False + MEMORY: # Deprecated, do not use GRAPH: SHOW: False RADIAL: