awesome-wm

Would it be unreasonably expensive to animate the wallpaper in AwesomeWM?


I was reading the source code for setting the wallpaper in awful.wallpaper and I found a few comments that suggest that animating the wallpaper would be very expensive. For example:

    -- Set the wallpaper.
    local pattern = cairo.Pattern.create_for_surface(target)
    capi.root.wallpaper(pattern)

    -- Limit some potential GC induced increase in memory usage.
    -- But really, is someone is trying to apply wallpaper changes more
    -- often than the GC is executed, they are doing it wrong.
    target:finish()
end

local mutex = false

-- Uploading the surface to X11 is *very* resource intensive. Given the updates
-- will often happen in batch (like startup), make sure to only do one "real"
-- update.
local function update()
    if mutex then return end

    mutex = true

    gtimer.delayed_call(function()
        -- Remove the mutex first in case `paint()` raises an exception.
        mutex = false
        paint()
    end)
end

My question is, given the current state, would it be too expensive to animate the wallpaper with 60+fps? And if yes, would there be a way around this?


Solution

  • If you want an animated wallpaper, set a video player as your root window. If you have multiple screens and keep creating/uploading them 60 time per second, you get:

    (1 byte per channel) * (3 channels) * (width) * (height) * (60), for a 4K display, that's 1.4 GB/s of data. Add the cost of painting, uploading and synchronizing and the awful.wallpaper own overhead, you literally don't have enough resource do it.

    Te reason video players and 3D games work at all is because a lot of the magic happens in the GPU and the texture/frames are compressed to a fraction of their raw size.

    That didn't prevent some people from doing it anyway, but it is a huge waste of resource. The way awesome does wallpaper by default is the least efficient way possible. It's also the most backward compatible way, which allows some terminal with "fake transparency" to work.