Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not monitor hardware sensors that are not used by the theme #540

Merged
merged 5 commits into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions library/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def wrap(
**kwargs
):
""" Wrapper to create our schedule and run it at the appropriate time """
if interval == 0:
return
scheduler = sched.scheduler(time.time, time.sleep)
periodic(scheduler, interval, func)
scheduler.run()
Expand All @@ -79,83 +81,83 @@ def wrap(


@async_job("CPU_Percentage")
@schedule(timedelta(seconds=config.THEME_DATA['STATS']['CPU']['PERCENTAGE'].get("INTERVAL", None)).total_seconds())
@schedule(timedelta(seconds=config.THEME_DATA['STATS']['CPU']['PERCENTAGE'].get("INTERVAL", 0)).total_seconds())
def CPUPercentage():
""" Refresh the CPU Percentage """
# logger.debug("Refresh CPU Percentage")
stats.CPU.percentage()


@async_job("CPU_Frequency")
@schedule(timedelta(seconds=config.THEME_DATA['STATS']['CPU']['FREQUENCY'].get("INTERVAL", None)).total_seconds())
@schedule(timedelta(seconds=config.THEME_DATA['STATS']['CPU']['FREQUENCY'].get("INTERVAL", 0)).total_seconds())
def CPUFrequency():
""" Refresh the CPU Frequency """
# logger.debug("Refresh CPU Frequency")
stats.CPU.frequency()


@async_job("CPU_Load")
@schedule(timedelta(seconds=config.THEME_DATA['STATS']['CPU']['LOAD'].get("INTERVAL", None)).total_seconds())
@schedule(timedelta(seconds=config.THEME_DATA['STATS']['CPU']['LOAD'].get("INTERVAL", 0)).total_seconds())
def CPULoad():
""" Refresh the CPU Load """
# logger.debug("Refresh CPU Load")
stats.CPU.load()


@async_job("CPU_Load")
@schedule(timedelta(seconds=config.THEME_DATA['STATS']['CPU']['TEMPERATURE'].get("INTERVAL", None)).total_seconds())
@schedule(timedelta(seconds=config.THEME_DATA['STATS']['CPU']['TEMPERATURE'].get("INTERVAL", 0)).total_seconds())
def CPUTemperature():
""" Refresh the CPU Temperature """
# logger.debug("Refresh CPU Temperature")
stats.CPU.temperature()


@async_job("CPU_FanSpeed")
@schedule(timedelta(seconds=config.THEME_DATA['STATS']['CPU']['FAN_SPEED'].get("INTERVAL", None)).total_seconds())
@schedule(timedelta(seconds=config.THEME_DATA['STATS']['CPU']['FAN_SPEED'].get("INTERVAL", 0)).total_seconds())
def CPUFanSpeed():
""" Refresh the CPU Fan Speed """
# logger.debug("Refresh CPU Fan Speed")
stats.CPU.fan_speed()


@async_job("GPU_Stats")
@schedule(timedelta(seconds=config.THEME_DATA['STATS']['GPU'].get("INTERVAL", None)).total_seconds())
@schedule(timedelta(seconds=config.THEME_DATA['STATS']['GPU'].get("INTERVAL", 0)).total_seconds())
def GpuStats():
""" Refresh the GPU Stats """
# logger.debug("Refresh GPU Stats")
stats.Gpu.stats()


@async_job("Memory_Stats")
@schedule(timedelta(seconds=config.THEME_DATA['STATS']['MEMORY'].get("INTERVAL", None)).total_seconds())
@schedule(timedelta(seconds=config.THEME_DATA['STATS']['MEMORY'].get("INTERVAL", 0)).total_seconds())
def MemoryStats():
# logger.debug("Refresh memory stats")
stats.Memory.stats()


@async_job("Disk_Stats")
@schedule(timedelta(seconds=config.THEME_DATA['STATS']['DISK'].get("INTERVAL", None)).total_seconds())
@schedule(timedelta(seconds=config.THEME_DATA['STATS']['DISK'].get("INTERVAL", 0)).total_seconds())
def DiskStats():
# logger.debug("Refresh disk stats")
stats.Disk.stats()


@async_job("Net_Stats")
@schedule(timedelta(seconds=config.THEME_DATA['STATS']['NET'].get("INTERVAL", None)).total_seconds())
@schedule(timedelta(seconds=config.THEME_DATA['STATS']['NET'].get("INTERVAL", 0)).total_seconds())
def NetStats():
# logger.debug("Refresh net stats")
stats.Net.stats()


@async_job("Date_Stats")
@schedule(timedelta(seconds=config.THEME_DATA['STATS']['DATE'].get("INTERVAL", None)).total_seconds())
@schedule(timedelta(seconds=config.THEME_DATA['STATS']['DATE'].get("INTERVAL", 0)).total_seconds())
def DateStats():
# logger.debug("Refresh date stats")
stats.Date.stats()


@async_job("Custom_Stats")
@schedule(timedelta(seconds=config.THEME_DATA['STATS']['CUSTOM'].get("INTERVAL", None)).total_seconds())
@schedule(timedelta(seconds=config.THEME_DATA['STATS']['CUSTOM'].get("INTERVAL", 0)).total_seconds())
def CustomStats():
# print("Refresh custom stats")
stats.Custom.stats()
Expand Down
1 change: 1 addition & 0 deletions res/themes/Cyberdeck/theme.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ STATS:
# BACKGROUND_COLOR: 132, 154, 165
BACKGROUND_IMAGE: background.png
FAN_SPEED:
INTERVAL: 5
RADIAL:
SHOW: True
X: 170
Expand Down
22 changes: 11 additions & 11 deletions res/themes/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
STATS:
CPU:
PERCENTAGE:
INTERVAL: 100
INTERVAL: 0
TEXT:
SHOW: False
GRAPH:
Expand All @@ -13,7 +13,7 @@ STATS:
LINE_GRAPH:
SHOW: False
FREQUENCY:
INTERVAL: 100
INTERVAL: 0
TEXT:
SHOW: False
GRAPH:
Expand All @@ -23,7 +23,7 @@ STATS:
LINE_GRAPH:
SHOW: False
LOAD:
INTERVAL: 100
INTERVAL: 0
ONE:
TEXT:
SHOW: False
Expand All @@ -34,7 +34,7 @@ STATS:
TEXT:
SHOW: False
TEMPERATURE:
INTERVAL: 100
INTERVAL: 0
TEXT:
SHOW: False
GRAPH:
Expand All @@ -44,7 +44,7 @@ STATS:
LINE_GRAPH:
SHOW: False
FAN_SPEED:
INTERVAL: 100
INTERVAL: 0
TEXT:
SHOW: False
GRAPH:
Expand All @@ -54,7 +54,7 @@ STATS:
LINE_GRAPH:
SHOW: False
GPU:
INTERVAL: 100
INTERVAL: 0
PERCENTAGE:
GRAPH:
SHOW: False
Expand Down Expand Up @@ -120,7 +120,7 @@ STATS:
LINE_GRAPH:
SHOW: False
MEMORY:
INTERVAL: 100
INTERVAL: 0
SWAP:
GRAPH:
SHOW: False
Expand All @@ -144,7 +144,7 @@ STATS:
PERCENT_TEXT:
SHOW: False
DISK:
INTERVAL: 100
INTERVAL: 0
USED:
GRAPH:
SHOW: False
Expand All @@ -163,7 +163,7 @@ STATS:
TEXT:
SHOW: False
NET:
INTERVAL: 100
INTERVAL: 0
WLO:
UPLOAD:
TEXT:
Expand Down Expand Up @@ -199,12 +199,12 @@ STATS:
TEXT:
SHOW: False
DATE:
INTERVAL: 100
INTERVAL: 0
DAY:
TEXT:
SHOW: False
HOUR:
TEXT:
SHOW: False
CUSTOM:
INTERVAL: 100
INTERVAL: 0
1 change: 1 addition & 0 deletions res/themes/theme_example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ STATS:
# In seconds. Longer intervals cause this to refresh more slowly.
# Setting to lower values will display near real time data,
# but may cause significant CPU usage or the display not to update properly
# Note: refresh interval is common to all GPU sensors
INTERVAL: 1
PERCENTAGE:
GRAPH:
Expand Down
33 changes: 22 additions & 11 deletions theme-editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,28 @@ def refresh_theme():

# Display all data on screen once
import library.stats as stats
stats.CPU.percentage()
stats.CPU.frequency()
stats.CPU.load()
stats.CPU.temperature()
stats.CPU.fan_speed()
stats.Gpu.stats()
stats.Memory.stats()
stats.Disk.stats()
stats.Net.stats()
stats.Date.stats()
stats.Custom.stats()
if config.THEME_DATA['STATS']['CPU']['PERCENTAGE'].get("INTERVAL", 0) > 0:
stats.CPU.percentage()
if config.THEME_DATA['STATS']['CPU']['FREQUENCY'].get("INTERVAL", 0) > 0:
stats.CPU.frequency()
if config.THEME_DATA['STATS']['CPU']['LOAD'].get("INTERVAL", 0) > 0:
stats.CPU.load()
if config.THEME_DATA['STATS']['CPU']['TEMPERATURE'].get("INTERVAL", 0) > 0:
stats.CPU.temperature()
if config.THEME_DATA['STATS']['CPU']['FAN_SPEED'].get("INTERVAL", 0) > 0:
stats.CPU.fan_speed()
if config.THEME_DATA['STATS']['GPU'].get("INTERVAL", 0) > 0:
stats.Gpu.stats()
if config.THEME_DATA['STATS']['MEMORY'].get("INTERVAL", 0) > 0:
stats.Memory.stats()
if config.THEME_DATA['STATS']['DISK'].get("INTERVAL", 0) > 0:
stats.Disk.stats()
if config.THEME_DATA['STATS']['NET'].get("INTERVAL", 0) > 0:
stats.Net.stats()
if config.THEME_DATA['STATS']['DATE'].get("INTERVAL", 0) > 0:
stats.Date.stats()
if config.THEME_DATA['STATS']['CUSTOM'].get("INTERVAL", 0) > 0:
stats.Custom.stats()


if __name__ == "__main__":
Expand Down
Loading