userconf.lua - dotfiles - leot's dotfiles
 (HTM) hg clone https://bitbucket.org/iamleot/dotfiles
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       userconf.lua
       ---
            1 local downloads = require "downloads"
            2 local editor = require "editor"
            3 local error_page = require "error_page"
            4 local modes = require "modes"
            5 local noscript = require "noscript"
            6 local settings = require "settings"
            7 local soup = require "soup"
            8 
            9 local marks = require "marks"
           10 
           11 -- Cookie policy ("never", "no_third_party", "always")
           12 soup.accept_policy = "never"
           13 
           14 -- Disable plugins and scripts
           15 noscript.enable_plugins = false
           16 noscript.enable_scripts = false
           17 
           18 editor.editor_cmd = "tmux new-window \"vi {file} ; tmux wait-for -S luakit-editor\" \\; wait-for luakit-editor"
           19 
           20 -- Search engines
           21 settings.window.search_engines = {
           22     default = "https://www.google.com/search?q=%s",
           23 
           24     aen = "https://www.amazon.com/s/ref=nb_sb_noss?field-keywords=%s",
           25     ait = "https://www.amazon.it/s/ref=nb_sb_noss?field-keywords=%s",
           26     bandcamp = "https://bandcamp.com/search?q=%s",
           27     cpan = "https://metacpan.org/search?q=%s",
           28     d = "https://duckduckgo.com/html/?q=%s",
           29     enfr = "https://wordreference.com/enfr/%s",
           30     enit = "https://wordreference.com/enit/%s",
           31     et = "http://www.treccani.it/enciclopedia/tag/%s/",
           32     fren = "http://wordreference.com/fren/%s",
           33     g = "https://www.google.com/search?q=%s",
           34     gi = "https://www.google.com/search?q=%s&tbm=isch",
           35     gl = "https://www.google.com/search?q=%s&btnI=I+feel+lucky",
           36     gs = "https://scholar.google.com/scholar?q=%s",
           37     imdb = "https://www.imdb.com/find?s=all&q=%s",
           38     iten = "https://wordreference.com/iten/%s",
           39     pypi = "https://pypi.org/search/?q=%s",
           40     rfc = "https://tools.ietf.org/html/rfc%s",
           41     vt = "http://www.treccani.it/vocabolario/tag/%s/",
           42     wa = "https://www.archive.org/searchresults.php?mediatype=web&Submit=Take+Me+Back&search=%s",
           43     wen = "https://secure.wikimedia.org/wikipedia/en/w/index.php?title=Special%%3ASearch&search=%s&go=Go",
           44     wit = "https://secure.wikimedia.org/wikipedia/it/w/index.php?title=Special%%3ASearch&search=%s&go=Go",
           45     y = "https://www.youtube.com/results?search_query=%s",
           46 }
           47 
           48 -- Per-domain settings (and kludges)
           49 settings.on["mobile.twitter.com"].webview.user_agent = "curl/7.61.1"
           50 settings.on["youtu.be"].webview.user_agent = "curl/7.61.1"
           51 settings.on["youtube.com"].webview.user_agent = "curl/7.61.1"
           52 
           53 -- Prefer cache_dir over data_dir for files that should be temporary
           54 downloads.db_path = luakit.cache_dir .. "/downloads.db"
           55 downloads.cert_db_path = luakit.cache_dir .. "/allowed_certificates.db"
           56 soup.cookies_storage = luakit.cache_dir .. "/cookies.db"
           57 
           58 modes.remap_binds("normal", {
           59     { "b", "H", true},
           60     { "B", "L", true},
           61     {"<Control-n>", "gt", true},
           62     {"<Control-Right>", "gt", true},
           63     {"<Control-p>", "gT", true},
           64     {"<Control-Left>", "gT", true},
           65     { "p", "pp", true},
           66     { "P", "pt", true},
           67 })
           68 
           69 modes.add_binds("normal", {
           70     { "<Control-m>", "Open current URL with mpv", function (w)
           71         local uri = w.view.uri
           72         if uri then
           73            luakit.spawn(string.format("mpv %q", uri))
           74         end
           75     end },
           76     { "<Shift-Mouse1>", "Open link under cursor with plumb", function (w, m)
           77         if not m.context.editable then
           78             local uri = w.view.hovered_uri or w.view.uri
           79             if uri then
           80                 luakit.spawn(string.format("xplumb %q", uri))
           81             end
           82         end
           83     end },
           84     { ",tc", "Enable/disable cookies", function (w)
           85         if soup then
           86             if soup.accept_policy == "never" then
           87                 soup.accept_policy = "no_third_party"
           88                 w:notify("Cookies enabled")
           89             else
           90                 soup.accept_policy = "never"
           91                 w:notify("Cookies disabled")
           92             end
           93         end
           94     end },
           95 })
           96 
           97 modes.add_cmds({
           98     { ":cookies", "Set the cookies accept policy", function (w, o)
           99         if o.arg == "never" then
          100             soup.accept_policy = "never"
          101         elseif o.arg == "no_third_party" then
          102             soup.accept_policy = "no_third_party"
          103         elseif o.arg == "always" then
          104             soup.accept_policy = "always"
          105         end
          106     end },
          107 })