we asynchronous wallpapers now

This commit is contained in:
Izaya 2021-10-25 17:24:33 +11:00
parent 06d632dd8a
commit b64b7c0f95

49
rc.lua
View File

@ -165,25 +165,42 @@ local tasklist_buttons = gears.table.join(
awful.button({ }, 5, function ()
awful.client.focus.byidx(-1)
end))
local used_wallpapers = {}
local function set_wallpaper(s)
print(s)
local wpath
if s.geometry.width > s.geometry.height then -- landscape
wpath = "/home/izaya/Nextcloud/Pictures/Wallpapers"
else
else -- portrait
wpath = "/home/izaya/Nextcloud/Pictures/Wallpapers/Phone"
end
local tWP = {}
for line in io.popen(string.format('ls "%s"',wpath),"r"):read("*a"):gmatch("([^\n]+)") do
tWP[#tWP+1] = line
end
local rv
repeat
rv = tWP[math.random(1,#tWP)]
local width, height = io.popen(string.format('identify -format "%%w %%h" "%s/%s"',wpath,rv)):read("*a"):match("(%d+) (%d+)")
width, height = tonumber(width) or 0, tonumber(height) or 0
until width > s.geometry.width and height > s.geometry.height
gears.wallpaper.maximized(wpath .. "/" .. rv, s, false)
collectgarbage("step",4000)
return awful.spawn.easy_async_with_shell(string.format('ls "%s"',wpath), function(out)
local tWP = {}
for line in out:gmatch("[^\n]+") do
tWP[#tWP+1] = line
end
local rv, unique
repeat
unique = true
rv = tWP[math.random(1,#tWP)]
for k,v in pairs(used_wallpapers) do
if v == rv then
unique = false
end
end
until unique
awful.spawn.easy_async_with_shell(string.format('identify -format "%%w %%h" "%s/%s"',wpath,rv), function(out)
local width, height = out:match("(%d+) (%d+)")
width, height = tonumber(width) or 0, tonumber(height) or 0
print(width, height)
if width > s.geometry.width and height > s.geometry.height then
gears.wallpaper.maximized(wpath .. "/" .. rv, s, false)
used_wallpapers[s:index()] = rv
else
return set_wallpaper(s)
end
end)
end)
end
-- Re-set wallpaper when a screen's geometry changes (e.g. different resolution)
screen.connect_signal("property::geometry", set_wallpaper)
@ -614,11 +631,11 @@ awful.rules.rules = {
{ rule = { class = "Steam", name = "Steam" },
properties = {tag = "2", titlebars_enabled = false } },
{ rule = { class = "Steam", name = "Friends List.*"},
properties = {tag = "4", titlebars_enabled = false } },
properties = {tag = "5", titlebars_enabled = false } },
{ rule = { class = "Pidgin"},
properties = {tag = "4"} },
properties = {tag = "5"} },
{ rule = { class = "Gajim", name = ".*File Transfer.*"},
properties = {tag = "3", floating = true } },
properties = {tag = "4", floating = true } },
}
-- }}}