From a9affb5ae42236ce9893382f6264a37e71777a06 Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Thu, 4 Sep 2025 19:15:50 +0200 Subject: [PATCH] Hooks: expose to grab the screen name --- Modules/SettingsPanel/Tabs/HooksTab.qml | 7 ++++++- Services/HooksService.qml | 5 +++-- Services/WallpaperService.qml | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Modules/SettingsPanel/Tabs/HooksTab.qml b/Modules/SettingsPanel/Tabs/HooksTab.qml index af1ca2e..195844c 100644 --- a/Modules/SettingsPanel/Tabs/HooksTab.qml +++ b/Modules/SettingsPanel/Tabs/HooksTab.qml @@ -47,7 +47,7 @@ ScrollView { } onActionClicked: { if (wallpaperHookInput.text) { - HooksService.executeWallpaperHook("test") + HooksService.executeWallpaperHook("test", "test-screen") } } Layout.fillWidth: true @@ -88,6 +88,11 @@ ScrollView { label: "Hook Command Information" description: "• Commands are executed via shell (sh -c)\n• Commands run in background (detached)\n• Test buttons execute with current values" } + + NLabel { + label: "Available Parameters" + description: "• Wallpaper Hook: $1 = wallpaper path, $2 = screen name\n• Theme Toggle Hook: $1 = true/false (dark mode state)" + } } } } diff --git a/Services/HooksService.qml b/Services/HooksService.qml index bcbf193..b14e3d6 100644 --- a/Services/HooksService.qml +++ b/Services/HooksService.qml @@ -17,7 +17,7 @@ Singleton { } // Execute wallpaper change hook - function executeWallpaperHook(wallpaperPath) { + function executeWallpaperHook(wallpaperPath, screenName) { if (!Settings.data.hooks?.enabled) { return } @@ -28,7 +28,8 @@ Singleton { } try { - const command = script.replace(/\$1/g, wallpaperPath) + let command = script.replace(/\$1/g, wallpaperPath) + command = command.replace(/\$2/g, screenName || "") Quickshell.execDetached(["sh", "-c", command]) Logger.log("HooksService", `Executed wallpaper hook: ${command}`) } catch (e) { diff --git a/Services/WallpaperService.qml b/Services/WallpaperService.qml index 897a9fd..2662061 100644 --- a/Services/WallpaperService.qml +++ b/Services/WallpaperService.qml @@ -288,7 +288,7 @@ Singleton { // Execute wallpaper change hook after the change is complete if (HooksService) { - HooksService.executeWallpaperHook(path) + HooksService.executeWallpaperHook(path, screenName) } // Restart the random wallpaper timer