Using the window manager Awesome, I run this after setting the background so that next time awesome starts I have a new background. I wrote it in Lua to stay with Awesome's lua "theme" and because I am already familiar with that and not at all with bash.
The first bit gets a json response with all the url's of pictures in the "epic" gallery from that site. I then convert the json into a table. Its a POST request rather then a GET as I noticed that the AJAX call on that site is also a POST. It probably doesn't matter though if it was a GET or POST.
After that it selects 2 pictures to be downloaded. I download 2 because I have 2 monitors. I probably should change the paths it uses one day so it stays in ~/.config/awesome and maybe I will make it change the wallpaper automatically as well.
- Code: Select all
function getBackground()
local JSON = assert(loadfile "/home/lenscas/.config/awesome/default/extraLua/JSON.lua")() -- one-time load of the routines
local f = assert (io.popen ('curl --data "" http://chillstep.info/jsonLoadGal.php?gal=gal-epic'))
local rawText="";
for line in f:lines() do
rawText=rawText..line
end -- for loop
f:close()
local inJson = JSON:decode(rawText)
math.randomseed(os.time())
local key=math.random(1,#inJson)
--print(table.concat(inJson))
os.execute('wget http://chillstep.info'..inJson[key]..' -O /home/lenscas/backgrounds/awesome/background1')
local key=math.random(1,#inJson)
os.execute('wget http://chillstep.info'..inJson[key]..' -O /home/lenscas/backgrounds/awesome/background2')
end
getBackground()