Easy Upgrading
It's been a while since luakit asked you to replace your rc.lua, but
just in case I've put all my customisation into
.config/luakit/userconf.lua
. Then the only change I need
to make in rc.lua is appending:
-- Put "userconf.lua" in your Luakit config dir with your own tweaks; if this is -- permanent, no need to copy/paste/modify the default rc.lua whenever you -- update Luakit. if pcall(function () lousy.util.find_config("userconf.lua") end) then require "userconf" end
For: .config/luakit/rc.lua
Change to New Tab on Middle Click
I'm not quite sure what the logic is of opening links in the background on a middle-click (I wouldn't be clicking is if I didn't want to look it it, no?). Still, this is luakit, so it's easy to fix. Just add
-- Switch to a new tab on a middle click, and don't do the selection -- thing of the distribution (in the rare cases I want that, I do pp). add_binds("all", { {"<Mouse2>", [[Open link under mouse cursor in new tab.]], function(w, m) local uri = w.view.hovered_uri if uri then w:new_tab(uri, { switch = true, private = w.view.private }) end end } })
For: .config/luakit/userconf.lua
to your userconf.
Vimperator-Compatible Textarea Editing
I came to luakit from Vimperator when Firefox grew too fat for the machine I was using back then. And I was so used to its keybindings that just had to restore the bindings I had in my fingers. So:
modes.remap_binds("insert", { { "<Control-i>", "<Control-e>", true }, }) add_binds("normal", { {"<Control-n>", "Go to next Tab.", function (w) w:next_tab() end}, {"<Control-p>", "Go to next Tab.", function (w) w:prev_tab() end}, { "0", "Scroll to the absolute left of the document.", function (w) w:scroll{ x = 0 } end },
For: .config/luakit/userconf.lua
Fix upstream stylesheets
If there's something I can't stand, it's upstream pages with excessive
column widths; IMHO, normal text starts becoming unreadable above a line
width of, say, 17cm. However, setting something like this globally
will mess up quite a few pages beyond repair. So, I'm using the following piece
of CSS/lua to quickly switch between sane p width and whatever
abomination comes from the page by hitting s
:
local style_override = stylesheet{ source = [===[ p, li, div { max-width: 30em; }]===]} add_binds("normal", { {"s", "Toggle user-defined stylesheets", function (w) local s = w.view.stylesheets; if s[style_override] then s[style_override] = nil else s[style_override] = true end end }, })
For: .config/luakit/userconf.lua
Have some overlap when scrolling a full page down
I like it if the old content does not vanish entirely when I page scroll less-like (i.e., hitting the space bar), and so I bind:
add_binds("normal", { {"<space>", "Scroll a page", function (w, m) w:scroll{ ypagerel = 0.9+((m.count or 1)-1) } end }, })
For: .config/luakit/userconf.lua
Block All Referrer Headers
The Referrer header probably is the worst invasion of privacy in all of RFC 2616, so I just globally kill them. There is a halfway legitimate use for them, though, in certain XSS protection schemes, so these rare cases I want to turn them on.
I hence wrote block_referers.lua and block_referers_wm.lua. Put both in your .luakit/config and add
require_web_module("block_referers_wm") require("block_referers")
For: .config/luakit/userconf.lua
into your userconf. Then switch between the modes with
,tf
(which is easy to memorise because if you, like me,
control who gets to execute javascript on my box,
,ts
will be in your fingers.
Yeah, I should have a display for the current state in the status line. But then I enable referrers so rarely and normally open new browser windows when I'm doing something else, so I've not felt this itch so far.
Toggle web storage
Call me paranoid, but I consider web local storage a particularly disgusting idea. Hence, I usually keep it off.
Regrettably, some pages I should really be boycotting fail really miserably without local storage (like... the page my bank – shame on you, Sparda-BaWü – forces me to use for bank transfers). So, I gave in and wrote a module webstorage_control.lua that turns web storage on and off. This time, there's a status bar display: Q is “local storage enabled”, q means sane mode.
Pass Through Escape
Given that, when Wifi operators are draconian enough to block port 22, one may need to run vi through hacks like shellinabox, the choice of Escape as the character that terminates the passthrough mode is perhaps suboptimal. Hence, I'm configuring
remove_binds("passthrough", {"<Escape>"}) add_binds("passthrough", { {"<Control-z>", "Return to normal mode", function (w) w:set_prompt(); w:set_mode() end }, })
For: .config/luakit/userconf.lua
Toggle Image Loading
I am sometimes on metered or slow lines, and that's when I miss the venerable Netscape's functionality to quickly switch between loading and not loading images.
Well, this is luakit, so here's how to have F10 do that:
add_binds("normal", { {"<F10>", "Toggle load images", function (w) local loading_images = settings.get_setting("webview.auto_load_images"); settings.set_setting("webview.auto_load_images", not loading_images); end}})
For: .config/luakit/userconf.lua
Again, a status line indicator might be nice. On the other hand, on a slow line you'll realise quickly whether or not you're loading images on today's ghastly pages.
Friendlier New Tab Page
I once wanted to have a cute sepia instead of the default new tab page (which I see quite a bit because I have many luakit windows with few tabs). This is a bit tricky because fiddling an external image into the page appears to be tricky.
What I ended up doing: I dumped a file newtab.html
into
~/.local/share/luakit/newtab.html
, where I style the body
element to have a background-image:
url('data:image/jpeg;base64:...'
. For instance: newtab.html
Don't Upgrade Insecure Requests
You may not be aware of it, but with any http request your browser sends out a message that you'd prefer https (it's called upgrade-insecure-requests). That may be what's ok for many people, I, for one, only prefer https in rather special circumstances. Mind you, I'm all for sensible encryption (a.k.a. PGP), but https often turns into a carnival, and it makes watching what web sites do on your machine (cf. disabling javascript) a good deal harder.
Anyway, I'd like to be able to choose what I prefer, and it seems webkit doesn't let you switch off that header.
Well, no_https_upgrade_wm.lua fixes that. Only use that if you know what you're doing; https may be a carnival, but it still helps here and there.
Clean Up History And Cookies
The fundament of data protection is removing data when it's no longer needed, and I've found an eternal history an unnecessary hazard. Hence, I have my computer crop it daily. Similarly, except for a few pages where cookies actually serve my interests (rather than someone else's or nobody's at all), I like to limit the lifetime of cookies.
Both are regular housekeeping jobs that I feel can be outside of the browser just as well. Hence, I'm running two cron jobs:
00 09 * * * ~/mybin/crop-luakit-history 01 09 * * * ~/mybin/clear_luakit_cookies.py
For: crontab -e
They are implemented in crop-luakit-history and
clear_luakit_cookies.py. The latter is configured
in .config/luakit/cookie.whitelist
to contain shell
patterns of hosts that are allowed to set persistent cookies.