Skip to content

Commit

Permalink
update ac power pathfinding
Browse files Browse the repository at this point in the history
  • Loading branch information
aarron-lee committed Oct 17, 2024
1 parent d3a53aa commit cc04a34
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
34 changes: 17 additions & 17 deletions py_modules/ac_power.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import os
from plugin_enums import AcPowerPaths
import device_utils
import decky_plugin

ACAD_DEVICES = [
# device_utils.Devices.GPD_WIN4.value,
device_utils.Devices.MINISFORUM_V3.value,
device_utils.Devices.LEGION_GO.value
]
ADP1_DEVICES = [
# device_utils.Devices.GPD_WM2.value
]
AC_POWER_PATH = None

def custom_ac_power_management_path():
device_name = device_utils.get_device_name()
global AC_POWER_PATH

ac_power_online_path = None
if bool(AC_POWER_PATH):
return AC_POWER_PATH

if device_name in ACAD_DEVICES:
ac_power_online_path = AcPowerPaths.ACAD.value
if device_name in ADP1_DEVICES:
ac_power_online_path = AcPowerPaths.ADP1.value
filename = None
try:
for n in os.listdir("/sys/class/power_supply"):
if n.startswith("AC") or n.startswith("ADP"):
filename = n

return ac_power_online_path
if filename is None:
return None
AC_POWER_PATH = f'/sys/class/power_supply/{filename}/online'
return AC_POWER_PATH
except Exception as e:
decky_plugin.logger.error(f"{__name__} custom ac power path error {e}")
return None

def supports_custom_ac_power_management():
ac_power_path = custom_ac_power_management_path()
Expand Down
6 changes: 0 additions & 6 deletions py_modules/plugin_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,3 @@ class GpuRange(Enum):
MIN = "minGpuFrequency"
MAX = "maxGpuFrequency"
FIXED = "fixedGpuFrequency"

class AcPowerPaths(Enum):
# Minisforum V3, LGO, Win 4
ACAD = '/sys/class/power_supply/ACAD/online'
# GPD WM2
ADP1 = '/sys/class/power_supply/ADP1/online'

0 comments on commit cc04a34

Please sign in to comment.