Skip to content

Commit 2a530f7

Browse files
committed
Added use external TDP feature
1 parent 34183aa commit 2a530f7

File tree

3 files changed

+104
-56
lines changed

3 files changed

+104
-56
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Turn off the display for background downloads to save battery. When enabled:
2222

2323
### Performance
2424

25+
- **Use External TDP** - Disable Ally Center's TDP management to use SimpleDeckyTDP or other plugins
2526
- **Performance Presets** - Quick switch between Download (5W), Silent (15W), Performance (25W), and Turbo (30W) modes
2627
- **TDP Override** - Manually set TDP from 5W to 30W with fine-grained control
2728
- **Fan Mode** - Choose between Auto, Quiet, Balanced, and Performance fan profiles

main.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,9 +942,21 @@ async def get_tdp_settings(self) -> dict:
942942
"min": 5,
943943
"max": 30,
944944
"tdp_override": self.settings.get("tdp_override", False),
945+
"use_external_tdp": self.settings.get("use_external_tdp", False),
945946
"available": os.path.exists(RYZENADJ_PATH) or os.path.exists("/sys/devices/platform/asus-nb-wmi")
946947
}
947948

949+
async def set_use_external_tdp(self, enabled: bool) -> bool:
950+
"""Enable/disable external TDP management (e.g., SimpleDeckyTDP)"""
951+
try:
952+
self.settings["use_external_tdp"] = enabled
953+
await self.save_settings()
954+
decky.logger.info(f"External TDP management {'enabled' if enabled else 'disabled'}")
955+
return True
956+
except Exception as e:
957+
decky.logger.error(f"Failed to set external TDP mode: {e}")
958+
return False
959+
948960
async def set_tdp(self, tdp: int) -> bool:
949961
try:
950962
tdp = max(5, min(30, tdp))

src/index.tsx

Lines changed: 91 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ const setCpuBoostEnabled = callable<[boolean], boolean>(
114114
"set_cpu_boost_enabled"
115115
);
116116
const getFanDiagnostics = callable<[], FanDiagnostics>("get_fan_diagnostics");
117+
const setUseExternalTdp = callable<[boolean], boolean>("set_use_external_tdp");
117118

118119
interface DeviceInfo {
119120
model: string;
@@ -196,6 +197,7 @@ interface TdpSettings {
196197
min: number;
197198
max: number;
198199
tdp_override: boolean;
200+
use_external_tdp: boolean;
199201
available: boolean;
200202
}
201203

@@ -798,6 +800,7 @@ const PerformanceSection: VFC = () => {
798800
const [currentTdp, setCurrentTdp] = useState(15);
799801
const [currentFanMode, setCurrentFanMode] = useState("auto");
800802
const [tdpOverride, setTdpOverrideState] = useState(false);
803+
const [useExternalTdp, setUseExternalTdpState] = useState(false);
801804

802805
useEffect(() => {
803806
const fetchData = async () => {
@@ -813,6 +816,7 @@ const PerformanceSection: VFC = () => {
813816
setCurrentFanMode(fan.mode);
814817
setCurrentTdp(tdpSettings.tdp);
815818
setTdpOverrideState(tdpSettings.tdp_override || false);
819+
setUseExternalTdpState(tdpSettings.use_external_tdp || false);
816820
} catch (e) {
817821
console.error("Failed to get performance data:", e);
818822
}
@@ -885,6 +889,22 @@ const PerformanceSection: VFC = () => {
885889
}
886890
};
887891

892+
const handleExternalTdpToggle = async (enabled: boolean) => {
893+
setUseExternalTdpState(enabled);
894+
await setUseExternalTdp(enabled);
895+
if (enabled) {
896+
toaster.toast({
897+
title: "Ally Center",
898+
body: "TDP managed by external plugin",
899+
});
900+
} else {
901+
toaster.toast({
902+
title: "Ally Center",
903+
body: "TDP managed by Ally Center",
904+
});
905+
}
906+
};
907+
888908
if (loading) {
889909
return (
890910
<PanelSection title="Performance">
@@ -902,9 +922,11 @@ const PerformanceSection: VFC = () => {
902922
<div style={infoRowStyle}>
903923
<span style={labelStyle}>Profile</span>
904924
<span
905-
style={{ ...valueStyle, color: tdpOverride ? "#ff9800" : "#fff" }}
925+
style={{ ...valueStyle, color: useExternalTdp ? "#8b929a" : (tdpOverride ? "#ff9800" : "#fff") }}
906926
>
907-
{tdpOverride
927+
{useExternalTdp
928+
? "External"
929+
: tdpOverride
908930
? "Manual"
909931
: profilesData?.profiles[profilesData.current]?.name ||
910932
"Unknown"}
@@ -921,68 +943,81 @@ const PerformanceSection: VFC = () => {
921943

922944
<PanelSectionRow>
923945
<ToggleField
924-
label="TDP Override"
925-
checked={tdpOverride}
926-
onChange={handleTdpOverrideToggle}
946+
label="Use External TDP"
947+
description="Let SimpleDeckyTDP or other plugins manage TDP"
948+
checked={useExternalTdp}
949+
onChange={handleExternalTdpToggle}
927950
/>
928951
</PanelSectionRow>
929952

930-
<PanelSectionRow>
931-
<SliderField
932-
label={`TDP: ${currentTdp}W`}
933-
value={currentTdp}
934-
min={5}
935-
max={30}
936-
step={1}
937-
disabled={!tdpOverride}
938-
showValue={false}
939-
onChange={handleTdpChange}
940-
/>
941-
</PanelSectionRow>
953+
{!useExternalTdp && (
954+
<div>
955+
<PanelSectionRow>
956+
<ToggleField
957+
label="TDP Override"
958+
checked={tdpOverride}
959+
onChange={handleTdpOverrideToggle}
960+
/>
961+
</PanelSectionRow>
942962

943-
<PanelSectionRow>
944-
<ButtonItem layout="below" onClick={() => setExpanded(!expanded)}>
945-
{expanded ? "Performance Presets ▲" : "Performance Presets ▼"}
946-
</ButtonItem>
947-
</PanelSectionRow>
963+
<PanelSectionRow>
964+
<SliderField
965+
label={`TDP: ${currentTdp}W`}
966+
value={currentTdp}
967+
min={5}
968+
max={30}
969+
step={1}
970+
disabled={!tdpOverride}
971+
showValue={false}
972+
onChange={handleTdpChange}
973+
/>
974+
</PanelSectionRow>
948975

949-
{expanded && profilesData && (
950-
<div>
951-
{Object.entries(profilesData.profiles).map(([id, profile]) => (
952-
<PanelSectionRow key={id}>
953-
<ButtonItem
954-
layout="below"
955-
onClick={() => handleProfileSelect(id)}
956-
>
957-
<div
958-
style={{
959-
display: "flex",
960-
justifyContent: "space-between",
961-
alignItems: "center",
962-
width: "100%",
963-
}}
964-
>
965-
<div>
966-
<span
976+
<PanelSectionRow>
977+
<ButtonItem layout="below" onClick={() => setExpanded(!expanded)}>
978+
{expanded ? "Performance Presets ▲" : "Performance Presets ▼"}
979+
</ButtonItem>
980+
</PanelSectionRow>
981+
982+
{expanded && profilesData && (
983+
<div>
984+
{Object.entries(profilesData.profiles).map(([id, profile]) => (
985+
<PanelSectionRow key={id}>
986+
<ButtonItem
987+
layout="below"
988+
onClick={() => handleProfileSelect(id)}
989+
>
990+
<div
967991
style={{
968-
fontWeight:
969-
profilesData.current === id ? "bold" : "normal",
970-
color: profilesData.current === id ? "#1a9fff" : "#fff",
992+
display: "flex",
993+
justifyContent: "space-between",
994+
alignItems: "center",
995+
width: "100%",
971996
}}
972997
>
973-
{profile.name}
974-
</span>
975-
{profilesData.current === id && (
976-
<span style={{ color: "#1a9fff", marginLeft: "8px" }}>
977-
978-
</span>
979-
)}
980-
</div>
981-
<span style={{ color: "#8b929a" }}>{profile.tdp}W</span>
982-
</div>
983-
</ButtonItem>
984-
</PanelSectionRow>
985-
))}
998+
<div>
999+
<span
1000+
style={{
1001+
fontWeight:
1002+
profilesData.current === id ? "bold" : "normal",
1003+
color: profilesData.current === id ? "#1a9fff" : "#fff",
1004+
}}
1005+
>
1006+
{profile.name}
1007+
</span>
1008+
{profilesData.current === id && (
1009+
<span style={{ color: "#1a9fff", marginLeft: "8px" }}>
1010+
1011+
</span>
1012+
)}
1013+
</div>
1014+
<span style={{ color: "#8b929a" }}>{profile.tdp}W</span>
1015+
</div>
1016+
</ButtonItem>
1017+
</PanelSectionRow>
1018+
))}
1019+
</div>
1020+
)}
9861021
</div>
9871022
)}
9881023

0 commit comments

Comments
 (0)