mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-06-08 04:09:15 -04:00
plugins: add support for composite plugins
- single plugin can register multiple types - e.g. daemon, bar widget, desktop widget
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
import QtQuick
|
||||
import Quickshell.Io
|
||||
import qs.Common
|
||||
import qs.Services
|
||||
import qs.Modules.Plugins
|
||||
|
||||
PluginComponent {
|
||||
id: root
|
||||
|
||||
property string scriptPath: pluginData.scriptPath || ""
|
||||
property var popoutService: null
|
||||
|
||||
Connections {
|
||||
target: SessionData
|
||||
function onWallpaperPathChanged() {
|
||||
if (scriptPath) {
|
||||
var scriptProcess = scriptProcessComponent.createObject(root, {
|
||||
wallpaperPath: SessionData.wallpaperPath
|
||||
});
|
||||
scriptProcess.running = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: scriptProcessComponent
|
||||
|
||||
Process {
|
||||
property string wallpaperPath: ""
|
||||
|
||||
command: [scriptPath, wallpaperPath]
|
||||
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
if (text.trim()) {
|
||||
console.log("CompositeDaemon script output:", text.trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stderr: StdioCollector {
|
||||
onStreamFinished: {
|
||||
if (text.trim()) {
|
||||
ToastService.showError("Wallpaper Change Script Error", text.trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onExited: exitCode => {
|
||||
if (exitCode !== 0) {
|
||||
ToastService.showError("Wallpaper Change Script Error", "Script exited with code: " + exitCode);
|
||||
}
|
||||
destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IpcHandler {
|
||||
target: "compositeExample"
|
||||
|
||||
function runHook(): string {
|
||||
if (!root.scriptPath)
|
||||
return "no script configured";
|
||||
var scriptProcess = scriptProcessComponent.createObject(root, {
|
||||
wallpaperPath: SessionData.wallpaperPath
|
||||
});
|
||||
scriptProcess.running = true;
|
||||
return "ran hook";
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
console.info("CompositeDaemon: Started monitoring wallpaper changes");
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
console.info("CompositeDaemon: Stopped monitoring wallpaper changes");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user