Cycling Random Wallpaper Or Xscreensaver

Note : Don't use BOTH functions at the same time, as the screensaver will overwrite the picture!

You will need to seed the random number generator and "pop a few" ( official term from the lua documentation) first. If you don't do this you will always have the same sequence. Add those lines before adding any of the following code snippets :

-- seed and "pop a few" math.randomseed( os.time) for i=1,1000 do tmp=math.random(0,1000) end

Change the wallpaper randomly (for awesome >= 3.5) :
add this to your rc.lua

-- configuration - edit to your liking wp_index = 1 wp_timeout = 10 wp_path = "/path/to/wallpapers/" wp_files = { "01.jpg", "02.jpg", "03.jpg" } -- setup the timer wp_timer = timer { timeout = wp_timeout } wp_timer:connect_signal("timeout", function -- set wallpaper to current index  gears.wallpaper.maximized( wp_path .. wp_files[wp_index], s, true) -- 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

Change the wallpaper randomly after a (relatively random) time (for awesome <= 3.4) :
add this to your rc.lua

x = 0

-- setup the timer mytimer = timer { timeout = x } mytimer:connect_signal("timeout", function

-- tell awsetbg to randomly choose a wallpaper from your wallpaper directory os.execute("awsetbg -T -r /usr/share/wallpapers&")

-- stop the timer (we don't need multiple instances running at the same time) mytimer:stop

-- define the interval in which the next wallpaper change should occur in seconds -- (in this case anytime between 10 and 20 minutes) x = math.random( 600, 1200)

--restart the timer mytimer.timeout = x mytimer:start end)

-- initial start when rc.lua is first run mytimer:start

Use an xscreensaver module as an animated wallpaper and switch to another after some time
(Warning : using transparency with this will result in weird effects and in the worst case scenario you won't see anything but the wallpaper!)

So your CPU is idling most of the time and you want some funky eye candy? Here is your solution : run a screensaver as wallpaper! You will need to install xscreensaver first, then add the following code to your rc.lua :

x= 0

-- setup the timer mytimer = timer { timeout = x } mytimer:connect_signal("timeout", function

-- list the wallpaper you want to use (They can be found in /usr/lib/xscreensaver/) followed by any additional -- parameters you need in a separate array element back = { "atlantis", "-whalespeed 826 -size 3027 -count 15", "substrate", "", "fliptext", "", "glmatrix", "-mode hex" }

-- kill any screensaver from the list that might be running for i=1, table.getn(back),2 do       os.execute("killall -I ".. back[i] .. " 2> /dev/null") end

-- set the background colour to black (just in case, as sometimes the screensavers seem to keep whatever is in the videobuffer) os.execute("xsetroot -bg black")

-- select a new screensaver y = math.random( 1, (table.getn(back)/2))-1 os.execute( "/usr/lib/xscreensaver/" .. back[ (y*2) + 1] .. " -root " .. back[ (y*2) + 2] .. "&")

-- define the interval in which the next wallpaper change should occur in seconds -- (in this case anytime between 10 and 20 minutes) x = math.random( 600, 1200)

-- reset the timer mytimer:stop mytimer.timeout = x   mytimer:start end)

-- initial start on the first run mytimer:start

Toggle the timer on and off
You will probably need a way to toggle the timer on and off. Add this block to mymainmenu in the default rc.lua to do that for the xscreensaver timer :

{ "toggle wallpaper", function

-- check whether the timer is running if mytimer.started then -- stop and set the timer to 0 mytimer:stop mytimer.timeout = 0 -- kill any running xscreensaver from the list used earlier on (no need for the parameters this time) back = { "atlantis", "substrate", "fliptext", "glmatrix" } for i=1, table.getn(back) do os.execute("killall -I ".. back[i] .. " 2> /dev/null") end -- optionally set a random static wallpaper os.execute("awsetbg -T -r /usr/share/wallpapers&") else -- reset and restart the timer mytimer.timeout = 0 mytimer:start end end },

Writing a toggle for the static wallpaper timer is similar (but much shorter)