Created Hook system (let's users run commands after specific actions)
NInputAction: create NTextInput with NButton HooksService: add dark/light mode hook, add wallpaper change hook HooksTab: create 1 NInputAction for each hook Wallpaper: add hook functionallity
This commit is contained in:
parent
d53a404bf1
commit
37eefe3663
9 changed files with 274 additions and 3 deletions
63
Services/HooksService.qml
Normal file
63
Services/HooksService.qml
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
pragma Singleton
|
||||
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import qs.Commons
|
||||
import qs.Services
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
// Hook connections for automatic script execution
|
||||
Connections {
|
||||
target: Settings.data.colorSchemes
|
||||
function onDarkModeChanged() {
|
||||
executeDarkModeHook(Settings.data.colorSchemes.darkMode)
|
||||
}
|
||||
}
|
||||
|
||||
// Execute wallpaper change hook
|
||||
function executeWallpaperHook(wallpaperPath) {
|
||||
if (!Settings.data.hooks?.enabled) {
|
||||
return
|
||||
}
|
||||
|
||||
const script = Settings.data.hooks?.wallpaperChange
|
||||
if (!script || script === "") {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const command = script.replace(/\$1/g, wallpaperPath)
|
||||
Quickshell.execDetached(["sh", "-c", command])
|
||||
Logger.log("HooksService", `Executed wallpaper hook: ${command}`)
|
||||
} catch (e) {
|
||||
Logger.error("HooksService", `Failed to execute wallpaper hook: ${e}`)
|
||||
}
|
||||
}
|
||||
|
||||
// Execute dark mode change hook
|
||||
function executeDarkModeHook(isDarkMode) {
|
||||
if (!Settings.data.hooks?.enabled) {
|
||||
return
|
||||
}
|
||||
|
||||
const script = Settings.data.hooks?.darkModeChange
|
||||
if (!script || script === "") {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const command = script.replace(/\$1/g, isDarkMode ? "true" : "false")
|
||||
Quickshell.execDetached(["sh", "-c", command])
|
||||
Logger.log("HooksService", `Executed dark mode hook: ${command}`)
|
||||
} catch (e) {
|
||||
Logger.error("HooksService", `Failed to execute dark mode hook: ${e}`)
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize the service
|
||||
function init() {
|
||||
Logger.log("HooksService", "Service initialized")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue