From ArchWiki
Jump to: navigation, search

Web pages snapshot with LuaKit

Hi, I would like to use LuaKit and ImageMagick (import) behind Xfvb to take snapshots of urls: start xfvb, start LuaKit on the new display and set the window size, get the first url, load the page, call import to take the first snapshot and save it, get the next url, load the page, etc...

Is there an advanced user of Lua and LuaKit to put me on the track?

Some idea

Hi, you can probably find it useful starting luakit with a lua file either directly or as an extension ever. Yet no idea how do we make it happen any elegant, while you still can post to

Luakit Bugtracker

Can be found in these projects: (Luakit original) (Plugins for Luakit little repo) (Luakit in the crowd, to bake fixes and make pull requests no-rotten) (Updated webkit2/gtk3 fork)

First try

I used unsuccessfully these two rc files:

-- uris to snapshot
uris = {

-- minimal rc from /etc/xdg/luakit/rc.lua
require "lfs"
require "lousy"
function warn(...) io.stderr:write(string.format(...) .. "\n") end
function info(...) if luakit.verbose then io.stdout:write(string.format(...) .. "\n") end end
require "globals"
theme = assert(lousy.theme.get(), "failed to load theme")
require "window"
require "webview"
require "modes"

--  my lua extension
if #uris
 local w = lousy.util.table.values(window.bywidget)[1] = true
 for _, uri in ipairs(uris)
  w.view.uri = uri
  uri = string.gsub(uri, "/", "_")
  os.execute("import -window root "..uri..".png")

Snapshots are made but before the LuaKit window is opened... I tried to introduce a sleep but the LuaKit window is never opened...

 for _, uri in ipairs(uris)
  w.view.uri = uri
  while w.view:loading() do os.execute("sleep 1s") end
  uri = string.gsub(uri, "/", "_")
  os.execute("import -window root "..uri..".png")

Need a proper delay

As far as I get, you may require to wait until luakit comes to idle state after it went to the URIs you passed. This can be achieved using luakit.idle_add( callback ). Also, if making snapshots of sites with tools like CutyCapt is not elegant enough (as seen on Wiki:, I could try to help you how ever I can.

Plaque FCC (talk) 07:10, 13 May 2013 (UTC)