local wallpaper = {} wallpaper.active = -1 -- How many minutes have passed since 00:00 wallpaper.timenow = function() local time = {} for t in string.gmatch(os.date("%H:%M"), "[^:]+") do table.insert(time, t) end return (tonumber(time[1]) * 60) + tonumber(time[2]) end -- Return wallpaper's start time in minutes since 00:00 wallpaper.get_start_time = function(entry) return (entry.start_time[1] * 60) + entry.start_time[2] end -- Set the ith wallpaper wallpaper.set = function(i) local path = beautiful.wallpaper[i].file wallpaper.active = i -- Set wallpaper maximized on each display for s in screen do gears.wallpaper.maximized(path, s) end end -- Which image should be scheduled now? wallpaper.current = function() for i = #beautiful.wallpaper, 1, -1 do if wallpaper.get_start_time(beautiful.wallpaper[i]) <= wallpaper.timenow() then return i end end end wallpaper.update = function() local current = wallpaper.current() if current ~= wallpaper.active then wallpaper.set(current) end return true end wallpaper.start = function() window.timer = gears.timer.start_new(10, wallpaper.update) end return wallpaper