import Quickshell.Io import QtQuick Item { id: wallpaperHolder // Store all wallpapers property var wallpapers: [] // path to the current wallpaper property string currentWallpaper: "" // process to run the command to change the wallpaper Process { id: wallpaperProcess onRunningChanged: { if (!running) { updateCurrentWallpaperProcess.running = true; // update the current wallpaper file after changing it } } } Process { id: updateCurrentWallpaperProcess command: ["bash", "-c", "cp " + wallpaperHolder.currentWallpaper + " ~/.config/hypr/current_wallpaper"] } // Load wallpaper list once at startup Process { id: loadWallpapers command: ["bash", "-c", "find ~/Pictures/wallpapers -type f"] stdout: StdioCollector { onStreamFinished: { console.log("wallpapers loaded!"); wallpaperHolder.wallpapers = this.text.trim().split("\n"); wallpaperHolder.setRandomWallpaper(); } } } function setRandomWallpaper() { if (wallpapers.length === 0) { console.log("No wallpapers found"); return; } var index = Math.floor(Math.random() * wallpapers.length); var path = wallpapers[index]; wallpaperHolder.currentWallpaper = path; wallpaperProcess.command = ["matugen", "image", path] console.log("Running command: " + wallpaperProcess.command); wallpaperProcess.running = true; currentWallpaper = path; } Timer { interval: 1000 * 60 * 15 // every 15 minutes running: true repeat: true onTriggered: wallpaperHolder.setRandomWallpaper() } Component.onCompleted: { loadWallpapers.running = true; // start loading wallpapers } }