diff options
Diffstat (limited to 'backend/decky_loader/utilities.py')
| -rw-r--r-- | backend/decky_loader/utilities.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/backend/decky_loader/utilities.py b/backend/decky_loader/utilities.py index 69c69fe6..63ffff06 100644 --- a/backend/decky_loader/utilities.py +++ b/backend/decky_loader/utilities.py @@ -214,7 +214,7 @@ class Utilities: async def http_request_legacy(self, method: str, url: str, extra_opts: Any = {}, timeout: int | None = None): async with ClientSession() as web: - res = await web.request(method, url, ssl=helpers.get_ssl_context(), timeout=timeout, **extra_opts) + res = await web.request(method, url, ssl=helpers.get_ssl_context(), timeout=timeout, **extra_opts) # type: ignore text = await res.text() return { "status": res.status, @@ -390,7 +390,6 @@ class Utilities: "total": len(all), } - # Based on https://stackoverflow.com/a/46422554/13174603 def start_rdt_proxy(self, ip: str, port: int): async def pipe(reader: StreamReader, writer: StreamWriter): @@ -474,3 +473,22 @@ class Utilities: async def get_tab_id(self, name: str): return (await get_tab(name)).id + + async def disable_plugin(self, name: str): + disabled_plugins: List[str] = await self.get_setting("disabled_plugins", []) + if name not in disabled_plugins: + disabled_plugins.append(name) + await self.set_setting("disabled_plugins", disabled_plugins) + + await self.context.plugin_loader.plugins[name].stop() + await self.context.ws.emit("loader/unload_plugin", name) + + async def enable_plugin(self, name: str): + disabled_plugins: List[str] = await self.get_setting("disabled_plugins", []) + if name in disabled_plugins: + disabled_plugins.remove(name) + await self.set_setting("disabled_plugins", disabled_plugins) + + plugin = self.context.plugin_loader.plugins[name] + plugin.start() + await self.context.plugin_loader.dispatch_plugin(plugin.name, plugin.version, plugin.load_type) |
