Search code examples
luascreenshotcairoawesome-wm

client's cairo surfaces screenshots


I just discovered screenshots possibilities using client.content property.
So to test this functionnality, I put this code and bind it to the XF86Reload key :

awful.key({  },        "XF86Reload",     function()                                                                        
     local i = 0                                                                                                          
     for c in awful.client.iterate(function() return true end)                                                            
     do                                                                                                                   
        local f = c.name                                                                                                  
        gears.surface(c.content):write_to_png( "/home/david/" .. string.format('%02i',i) .."-" .. f  ..  ".png")          
        i=i+1                                                                                                             
     end                                                                                                                  
end)

Unfortunately, some images are puzzled. Is the Cairo surface needs to be on the screen (ie non minimized) to be properly shot? (it seems it's also happening sometimes to visible windows) or maybe some other reason I can't see...


Solution

  • Is the Cairo surface needs to be on the screen (ie non minimized) to be properly shot?

    Yes (and also: may not be obscured by other windows or outside of the visible space; you can only get what is actually shown on the display).