Frequently Asked Questions

Jonas Schievink edited this page Feb 26, 2015 · 7 revisions

Русскоязычная версия

Downloads

How do I change the default download location?

In your rc.lua after require "downloads" add (or modify) the following:

downloads.default_dir = os.getenv("HOME") .. "/downloads"

How do I make all downloads save to my default download location without asking?

In your rc.lua after require "downloads" add (or modify) the following:

downloads.add_signal("download-location", function (uri, file)
    if not file or file == "" then
        file = (string.match(uri, "/([^/]+)$")
            or string.match(uri, "^%w+://(.+)")
            or string.gsub(uri, "/", "_")
            or "untitled")
    end
    return downloads.default_dir .. "/" .. file
end)

Behaviour

How do I stop some links opening in new windows?

Add your own "new-window-decision" webview signal handler which always opens links in new tabs.

In your rc.lua after require "webview" add (or modify) the following:

webview.init_funcs.window_decision = function (view, w)
    view:add_signal("new-window-decision", function (v, uri, reason)
        w:new_tab(uri)
        return true
    end)
end

Styling

A number of page styling tweaks can be made by adding additional page initialization functions. These are placed in the rc.lua file. They must be after require "webview", but before the block where the window or tab creation call is made. This happens near the end of the file, right after the comment End user script loading. This means that you cannot just add these functions to the end of the file, if you do so they will not be executed.

I'm using a dark theme how do I stop the white flash during the loading of a page?

This is easily done by setting the webview.transparent property so that the GTK window background style of your current theme will show through.

webview.init_funcs.set_win_trans = function (view, w)
    view.transparent = true
end

How do I change the default zoom level?

The following init function will set the zoom level property to 1.5 for a 50% zoom.

webview.init_funcs.set_default_zoom = function (view, w)
  view.full_content_zoom = true -- optional
  view.zoom_level = 1.5 -- a 50% zoom
end

How do I set a custom about:blank page?

You can do this easily by watching the "navigation-request" webview signal for navigation to specific addresses (in this case "about:blank").

webview.init_funcs.set_dark_about_blank = function (view, w)
    view:add_signal("navigation-request", function (_, uri)
        if uri == "about:blank" then
            view:load_string("<html><body bgcolor='#000000'></body></html>", "about:blank")
            return true
        end
    end)
end