-
Notifications
You must be signed in to change notification settings - Fork 0
/
schedule.js
37 lines (30 loc) · 896 Bytes
/
schedule.js
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
import { resolveScheduledColor } from "./colorUtils.js"
import { readConfig } from "./configUtils.js"
import { transitionToColor } from "./wallpaperUtils.js"
let isTransitioning = false // Flag to indicate if a transition is in progress
async function updateWallpaper() {
if (isTransitioning) {
console.log("Transition already in progress, skipping this run.")
return
}
const config = await readConfig()
const duration = config.duration || 0
const schedule = config.schedule
if (!schedule) {
console.log("No schedule found")
return
}
const color = resolveScheduledColor(schedule)
if (color) {
isTransitioning = true
try {
await transitionToColor(color, duration)
} finally {
isTransitioning = false
}
}
}
// Run updateWallpaper every minute
setInterval(updateWallpaper, 60 * 1000)
// Initial call to set the wallpaper immediately on start
updateWallpaper()