-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWallpaperShufflerDaemon.qml
More file actions
98 lines (85 loc) · 3.42 KB
/
WallpaperShufflerDaemon.qml
File metadata and controls
98 lines (85 loc) · 3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import QtQuick
import Quickshell
import Quickshell.Io
import qs.Common
import qs.Services
import qs.Modules.Plugins
PluginComponent{
id: root
// Expand tilde to home directory
function expandPath(path) {
if (path.startsWith("~/")) {
return Quickshell.env("HOME") + path.substring(1);
}
return path;
}
// Reactive binding that updates whenever pluginData.wallpaperPath changes
property string wallpaperPath: {
var path = pluginData.wallpaperPath || "~/Pictures";
return expandPath(path);
}
property int shuffleInterval: (pluginData.shuffleInterval || 1800) * 1000
property string scriptPath: Qt.resolvedUrl("shuffle-wallpapers").toString().replace("file://", "")
Component.onCompleted: {
console.log("=== Wallpaper Shuffler Plugin Started ===");
console.log("Wallpaper Path:", root.wallpaperPath);
console.log("Shuffle Interval:", root.shuffleInterval, "ms");
console.log("Script Path:", root.scriptPath);
// Immediately restore the current wallpaper from shuffle state to prevent
// system wallpaper daemon from taking over on boot
restoreCurrentWallpaperProcess.running = true;
}
Process {
id: shuffleProcess
command: []
running: false
onRunningChanged: {
console.log("Process running:", running);
if (!running) {
console.log("Wallpaper shuffled successfully");
}
}
onExited: (exitCode, exitStatus) => {
console.log("Process exited with code:", exitCode);
}
}
// Process to restore current wallpaper on startup (before timer fires)
Process {
id: restoreCurrentWallpaperProcess
command: ["bash", "-c",
`WALLPAPER_DIR="${root.wallpaperPath}"
SHUFFLE_FILE="$WALLPAPER_DIR/.dms-wallpaper-shuffler/wallpaper_shuffle_list"
CURRENT_INDEX_FILE="$WALLPAPER_DIR/.dms-wallpaper-shuffler/wallpaper_current_index"
# Check if shuffle state exists
if [ -f "$SHUFFLE_FILE" ] && [ -f "$CURRENT_INDEX_FILE" ]; then
current_index=$(cat "$CURRENT_INDEX_FILE")
current_wallpaper=$(sed -n "${current_index}p" "$SHUFFLE_FILE")
if [ -n "$current_wallpaper" ] && [ -f "$current_wallpaper" ]; then
echo "Restoring wallpaper: $current_wallpaper" >&2
dms ipc call wallpaper set "$current_wallpaper"
else
echo "No valid wallpaper to restore" >&2
fi
else
echo "No shuffle state found, will create on first timer trigger" >&2
fi`
]
running: false
onExited: exitCode => {
console.log("Wallpaper restoration completed with code:", exitCode);
}
}
Timer {
interval: root.shuffleInterval
running: true
repeat: true
triggeredOnStart: true
onTriggered: {
console.log("Timer triggered - starting shuffle process");
console.log("Using wallpaper path:", root.wallpaperPath);
// Set command right before running to ensure it uses the current wallpaperPath value
shuffleProcess.command = ["bash", root.scriptPath, root.wallpaperPath];
shuffleProcess.running = true;
}
}
}