summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/decky_loader/loader.py4
-rw-r--r--backend/decky_loader/utilities.py20
2 files changed, 23 insertions, 1 deletions
diff --git a/backend/decky_loader/loader.py b/backend/decky_loader/loader.py
index e2e619f7..09ec7465 100644
--- a/backend/decky_loader/loader.py
+++ b/backend/decky_loader/loader.py
@@ -78,6 +78,7 @@ class Loader:
self.live_reload = live_reload
self.reload_queue: ReloadQueue = Queue()
self.loop.create_task(self.handle_reloads())
+ self.context: PluginManager = server_instance
if live_reload:
self.observer = Observer()
@@ -164,6 +165,9 @@ class Loader:
await self.ws.emit(f"loader/plugin_event", {"plugin": plugin.name, "event": event, "args": args})
plugin = PluginWrapper(file, plugin_directory, self.plugin_path, plugin_emitted_event)
+ if hasattr(self.context, "utilities") and plugin.name in await self.context.utilities.get_setting("disabled_plugins",[]):
+ self.plugins[plugin.name] = plugin
+ return
if plugin.name in self.plugins:
if not "debug" in plugin.flags and refresh:
self.logger.info(f"Plugin {plugin.name} is already loaded and has requested to not be re-loaded")
diff --git a/backend/decky_loader/utilities.py b/backend/decky_loader/utilities.py
index 69c69fe6..ab2dde6f 100644
--- a/backend/decky_loader/utilities.py
+++ b/backend/decky_loader/utilities.py
@@ -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)