we asynchronous wallpapers now
This commit is contained in:
parent
06d632dd8a
commit
b64b7c0f95
35
rc.lua
35
rc.lua
@ -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
|
||||
return awful.spawn.easy_async_with_shell(string.format('ls "%s"',wpath), function(out)
|
||||
local tWP = {}
|
||||
for line in io.popen(string.format('ls "%s"',wpath),"r"):read("*a"):gmatch("([^\n]+)") do
|
||||
for line in out:gmatch("[^\n]+") do
|
||||
tWP[#tWP+1] = line
|
||||
end
|
||||
local rv
|
||||
local rv, unique
|
||||
repeat
|
||||
unique = true
|
||||
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+)")
|
||||
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
|
||||
until width > s.geometry.width and height > s.geometry.height
|
||||
print(width, height)
|
||||
if width > s.geometry.width and height > s.geometry.height then
|
||||
gears.wallpaper.maximized(wpath .. "/" .. rv, s, false)
|
||||
collectgarbage("step",4000)
|
||||
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 } },
|
||||
}
|
||||
-- }}}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user