generated from SteamDeckHomebrew/decky-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add utils mmodule, add ConfManager
- Loading branch information
Showing
9 changed files
with
131 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import decky | ||
from config import CONFIG_KEY | ||
from settings import SettingsManager | ||
|
||
|
||
class ConfManager: | ||
def __init__(self): | ||
self.sysSettings = SettingsManager( | ||
name="config", settings_directory=decky.DECKY_PLUGIN_SETTINGS_DIR | ||
) | ||
self.fansSettings = SettingsManager( | ||
name="fans_config", | ||
settings_directory=decky.DECKY_PLUGIN_SETTINGS_DIR, | ||
) | ||
|
||
def getSettings(self): | ||
return self.sysSettings.getSetting(CONFIG_KEY) | ||
|
||
def setSettings(self, settings): | ||
self.sysSettings.setSetting(CONFIG_KEY, settings) | ||
return True | ||
|
||
def getFanSettings(self): | ||
return self.fansSettings.getSetting(CONFIG_KEY) | ||
|
||
def setFanSettingsByKey(self, key, value): | ||
self.fansSettings.setSetting(key, value) | ||
return True | ||
|
||
|
||
confManager = ConfManager() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from .gpu_fix import fix_gpuFreqSlider_AMD, fix_gpuFreqSlider_INTEL | ||
from .tdp import getMaxTDP | ||
|
||
__all__ = [ | ||
"fix_gpuFreqSlider_AMD", | ||
"fix_gpuFreqSlider_INTEL", | ||
"getMaxTDP", | ||
] |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from config import ( | ||
CPU_ID, | ||
PRODUCT_NAME, | ||
TDP_LIMIT_CONFIG_CPU, | ||
TDP_LIMIT_CONFIG_PRODUCT, | ||
logger, | ||
) | ||
|
||
|
||
def getMaxTDP() -> int: | ||
"""获取最大TDP值。 | ||
Returns: | ||
int: 最大TDP值(瓦特) | ||
""" | ||
try: | ||
# 根据机器型号或者CPU型号返回tdp最大值 | ||
if PRODUCT_NAME in TDP_LIMIT_CONFIG_PRODUCT: | ||
cpu_tdpMax = TDP_LIMIT_CONFIG_PRODUCT[PRODUCT_NAME] | ||
else: | ||
for model in TDP_LIMIT_CONFIG_CPU: | ||
if model in CPU_ID: | ||
cpu_tdpMax = TDP_LIMIT_CONFIG_CPU[model] | ||
break | ||
else: | ||
cpu_tdpMax = 15 | ||
logger.info("getMaxTDP {}".format(cpu_tdpMax)) | ||
return cpu_tdpMax | ||
except Exception as e: | ||
logger.error("Failed to get max TDP value", exc_info=True) | ||
return 0 |