remove unused var and actually add new folder
This commit is contained in:
56
quickshell/services/RandomWallpaper.qml
Normal file
56
quickshell/services/RandomWallpaper.qml
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
import Quickshell
|
||||||
|
import Quickshell.Io
|
||||||
|
import QtQuick
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: wallpaperHolder
|
||||||
|
|
||||||
|
// Store all wallpapers
|
||||||
|
property var wallpapers: []
|
||||||
|
|
||||||
|
// process to run the command to change the wallpaper
|
||||||
|
Process {
|
||||||
|
id: wallpaperProcess
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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];
|
||||||
|
|
||||||
|
// console.log("wallpaper set to " + path);
|
||||||
|
|
||||||
|
wallpaperProcess.command = ["awww", "img", path, "--transition-type", "grow", "--transition-fps", "60", "--transition-duration", "0.6"];
|
||||||
|
|
||||||
|
wallpaperProcess.running = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
interval: 60000
|
||||||
|
running: true
|
||||||
|
repeat: true
|
||||||
|
onTriggered: wallpaperHolder.setRandomWallpaper()
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
loadWallpapers.running = true; // start loading wallpapers
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user