Skip to content

Commit cc04a34

Browse files
committed
update ac power pathfinding
1 parent d3a53aa commit cc04a34

File tree

2 files changed

+17
-23
lines changed

2 files changed

+17
-23
lines changed

py_modules/ac_power.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
import os
2-
from plugin_enums import AcPowerPaths
3-
import device_utils
2+
import decky_plugin
43

5-
ACAD_DEVICES = [
6-
# device_utils.Devices.GPD_WIN4.value,
7-
device_utils.Devices.MINISFORUM_V3.value,
8-
device_utils.Devices.LEGION_GO.value
9-
]
10-
ADP1_DEVICES = [
11-
# device_utils.Devices.GPD_WM2.value
12-
]
4+
AC_POWER_PATH = None
135

146
def custom_ac_power_management_path():
15-
device_name = device_utils.get_device_name()
7+
global AC_POWER_PATH
168

17-
ac_power_online_path = None
9+
if bool(AC_POWER_PATH):
10+
return AC_POWER_PATH
1811

19-
if device_name in ACAD_DEVICES:
20-
ac_power_online_path = AcPowerPaths.ACAD.value
21-
if device_name in ADP1_DEVICES:
22-
ac_power_online_path = AcPowerPaths.ADP1.value
12+
filename = None
13+
try:
14+
for n in os.listdir("/sys/class/power_supply"):
15+
if n.startswith("AC") or n.startswith("ADP"):
16+
filename = n
2317

24-
return ac_power_online_path
18+
if filename is None:
19+
return None
20+
AC_POWER_PATH = f'/sys/class/power_supply/{filename}/online'
21+
return AC_POWER_PATH
22+
except Exception as e:
23+
decky_plugin.logger.error(f"{__name__} custom ac power path error {e}")
24+
return None
2525

2626
def supports_custom_ac_power_management():
2727
ac_power_path = custom_ac_power_management_path()

py_modules/plugin_enums.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,3 @@ class GpuRange(Enum):
1111
MIN = "minGpuFrequency"
1212
MAX = "maxGpuFrequency"
1313
FIXED = "fixedGpuFrequency"
14-
15-
class AcPowerPaths(Enum):
16-
# Minisforum V3, LGO, Win 4
17-
ACAD = '/sys/class/power_supply/ACAD/online'
18-
# GPD WM2
19-
ADP1 = '/sys/class/power_supply/ADP1/online'

0 commit comments

Comments
 (0)