Skip to content

Commit

Permalink
Merge pull request #485 from majormer/main
Browse files Browse the repository at this point in the history
  • Loading branch information
mathoudebine authored Jul 21, 2024
2 parents 74fa90f + 0e32264 commit dbdf154
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
17 changes: 17 additions & 0 deletions library/sensors/sensors_librehardwaremonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
11 changes: 11 additions & 0 deletions library/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand Down Expand Up @@ -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']
Expand Down
5 changes: 4 additions & 1 deletion res/themes/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit dbdf154

Please sign in to comment.