mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
Add "daemon" type of plugins
This commit is contained in:
65
PLUGINS/WallpaperWatcherDaemon/WallpaperWatcherDaemon.qml
Normal file
65
PLUGINS/WallpaperWatcherDaemon/WallpaperWatcherDaemon.qml
Normal file
@@ -0,0 +1,65 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import qs.Common
|
||||
import qs.Services
|
||||
import qs.Modules.Plugins
|
||||
|
||||
PluginComponent {
|
||||
id: root
|
||||
|
||||
property string scriptPath: pluginData.scriptPath || ""
|
||||
|
||||
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("WallpaperWatcherDaemon 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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
console.log("WallpaperWatcherDaemon: Started monitoring wallpaper changes")
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
console.log("WallpaperWatcherDaemon: Stopped monitoring wallpaper changes")
|
||||
}
|
||||
}
|
||||
24
PLUGINS/WallpaperWatcherDaemon/WallpaperWatcherSettings.qml
Normal file
24
PLUGINS/WallpaperWatcherDaemon/WallpaperWatcherSettings.qml
Normal file
@@ -0,0 +1,24 @@
|
||||
import QtQuick
|
||||
import qs.Common
|
||||
import qs.Widgets
|
||||
import qs.Modules.Plugins
|
||||
|
||||
PluginSettings {
|
||||
id: root
|
||||
pluginId: "wallpaperWatcherDaemon"
|
||||
|
||||
StyledText {
|
||||
text: "Wallpaper Change Hook"
|
||||
font.pixelSize: Theme.fontSizeLarge
|
||||
font.weight: Font.Bold
|
||||
color: Theme.surfaceText
|
||||
}
|
||||
|
||||
StringSetting {
|
||||
settingKey: "scriptPath"
|
||||
label: "Script Path"
|
||||
description: "Path to a script that will be executed when the wallpaper changes. The new wallpaper path will be passed as the first argument."
|
||||
placeholder: "/path/to/your/script.sh"
|
||||
defaultValue: ""
|
||||
}
|
||||
}
|
||||
15
PLUGINS/WallpaperWatcherDaemon/plugin.json
Normal file
15
PLUGINS/WallpaperWatcherDaemon/plugin.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"id": "wallpaperWatcherDaemon",
|
||||
"name": "Wallpaper Watcher Daemon",
|
||||
"description": "Background daemon that monitors wallpaper changes and logs them",
|
||||
"version": "1.0.0",
|
||||
"author": "DankMaterialShell",
|
||||
"icon": "wallpaper",
|
||||
"type": "daemon",
|
||||
"component": "./WallpaperWatcherDaemon.qml",
|
||||
"settings": "./WallpaperWatcherSettings.qml",
|
||||
"permissions": [
|
||||
"settings_read",
|
||||
"settings_write"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user