Skip to content

Instantly share code, notes, and snippets.

Created March 25, 2015 13:04
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save anonymous/9072154f03247ab6e28c to your computer and use it in GitHub Desktop.
Save anonymous/9072154f03247ab6e28c to your computer and use it in GitHub Desktop.
-- {{{ Function definitions
-- scan directory, and optionally filter outputs
function scandir(directory, filter)
local i, t, popen = 0, {}, io.popen
if not filter then
filter = function(s) return true end
end
print(filter)
for filename in popen('ls -a "'..directory..'"'):lines() do
if filter(filename) then
i = i + 1
t[i] = filename
end
end
return t
end
-- }}}
-- configuration - edit to your liking
wp_index = 1
wp_timeout = 10
wp_path = "/path/to/wallpapers/"
wp_filter = function(s) return string.match(s,"%.png$") or string.match(s,"%.jpg$") end
wp_files = scandir(wp_path, wp_filter)
-- setup the timer
wp_timer = timer { timeout = wp_timeout }
wp_timer:connect_signal("timeout", function()
-- set wallpaper to current index for all screens
for s = 1, screen.count() do
gears.wallpaper.maximized(wp_path .. wp_files[wp_index], s, true)
end
-- stop the timer (we don't need multiple instances running at the same time)
wp_timer:stop()
-- get next random index
wp_index = math.random( 1, #wp_files)
--restart the timer
wp_timer.timeout = wp_timeout
wp_timer:start()
end)
-- initial start when rc.lua is first run
wp_timer:start()
}}
To rotate the wallpapers randomly, just comment the {{ic|wallpaper_cmd}} line above, and add a script into your {{ic|.xinitrc}} with the codes below(for awesome <= 3.4 ):
{{bc|
while true;
do
awsetbg -r <path/to/the/directory/of/your/wallpapers>
sleep 15m
done &
@Ruben-Madelaine
Copy link

I don't understand your line 52 ; is it a comment ??
(To rotate the wallpapers randomly, just comment the {{ic|wallpaper_cmd}} line above, and add a script into your {{ic|.xinitrc}} with the codes below(for awesome <= 3.4 ):
{{bc|)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment