Last active
December 16, 2015 15:29
-
-
Save zoqaeski/5456732 to your computer and use it in GitHub Desktop.
Config differences
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/etc/xdg/luakit/rc.lua b/home/robbie/.config/luakit/rc.lua | |
index c03a6bd..f2b0e7c 100644 | |
--- a/etc/xdg/luakit/rc.lua | |
+++ b/home/robbie/.config/luakit/rc.lua | |
@@ -145,6 +145,9 @@ require "go_input" | |
require "go_next_prev" | |
require "go_up" | |
+-- Extra plugins | |
+require "plugins" | |
+ | |
----------------------------- | |
-- End user script loading -- | |
----------------------------- | |
@@ -178,4 +181,116 @@ if unique then | |
end) | |
end | |
+------------------------------------------- | |
+-- Key Binding | |
+------------------------------------------- | |
+ | |
+-- Binding aliases | |
+local key, buf, but = lousy.bind.key, lousy.bind.buf, lousy.bind.but | |
+local cmd, any = lousy.bind.cmd, lousy.bind.any | |
+ | |
+add_binds("all", { | |
+ -- Open link in new tab or navigate to selection | |
+ but({}, 2, [[Open link under mouse cursor in new tab or navigate to the | |
+ contents of `luakit.selection.primary`.]], | |
+ function (w, m) | |
+ -- Ignore button 2 clicks in form fields | |
+ if not m.context.editable then | |
+ -- Open hovered uri in new tab | |
+ local uri = w.view.hovered_uri | |
+ if uri then | |
+ w:new_tab(uri, false) | |
+ end | |
+ end | |
+ end | |
+ ), | |
+}, true) | |
+ | |
+add_binds("normal", { | |
+ key({}, "D", "Scroll half page down.", | |
+ function (w) w:scroll{ ypagerel = 0.5 } end), | |
+ | |
+ key({}, "d", "Scroll half page down.", | |
+ function (w) w:scroll{ ypagerel = 0.5 } end), | |
+ | |
+ key({}, "u", "Scroll half page up.", | |
+ function (w) w:scroll{ ypagerel = -0.5 } end), | |
+ | |
+ key({"Control"}, "w", "Close current tab.", | |
+ function (w) if w.tabs:count() > 1 then w:close_tab() else w:close_win() end end), | |
+ | |
+ key({}, "x", "Close current tab (or `[count]` tabs).", | |
+ function (w, m) | |
+ for i=1,m.count do | |
+ if w.tabs:count() > 1 then w:close_tab() else w:close_win() end | |
+ end | |
+ end, {count=1}), | |
+ | |
+ key({}, "X", "Undo last closed tab (or `[count]` tabs).", | |
+ function (w, m) for i=1,m.count do w:undo_close_tab() end end, {count=1}), | |
+ | |
+ -- Clipboard | |
+ key({}, "p", [[Open a URL based on the current primary selection contents | |
+ in the current tab.]], | |
+ function (w) | |
+ local uri = luakit.selection.primary | |
+ if not uri then w:notify("No primary selection...") return end | |
+ w:navigate(w:search_open(uri)) | |
+ end), | |
+ | |
+ key({"Control"}, "p", [[Open a URL based on the current primary selection contents | |
+ in `[count=1]` new tab(s).]], | |
+ function (w, m) | |
+ local uri = luakit.selection.primary | |
+ if not uri then w:notify("No primary selection...") return end | |
+ for i = 1, m.count do w:new_tab(w:search_open(uri)) end | |
+ end, {count = 1}), | |
+ | |
+ key({}, "P", [[Open a URL based on the current clipboard contents | |
+ in the current tab.]], | |
+ function (w) | |
+ local uri = luakit.selection.clipboard | |
+ if not uri then w:notify("Nothing in clipboard...") return end | |
+ w:navigate(w:search_open(uri)) | |
+ end), | |
+ | |
+ key({"Shift","Control"}, "P", [[Open a URL based on the clipboard selection contents | |
+ in `[count=1]` new tab(s).]], | |
+ function (w, m) | |
+ local uri = luakit.selection.primary | |
+ if not uri then w:notify("Nothing in clipboard...") return end | |
+ for i = 1, m.count do w:new_tab(w:search_open(uri)) end | |
+ end, {count = 1}), | |
+ | |
+ -- Yanking | |
+ key({}, "y", "Yank current URI to primary selection.", | |
+ function (w) | |
+ local uri = string.gsub(w.view.uri or "", " ", "%%20") | |
+ luakit.selection.primary = uri | |
+ w:notify("Yanked uri: " .. uri) | |
+ end), | |
+ | |
+ key({}, "Y", "Yank current URI to clipboard.", | |
+ function (w) | |
+ local uri = string.gsub(w.view.uri or "", " ", "%%20") | |
+ luakit.selection.clipboard = uri | |
+ w:notify("Yanked uri (to clipboard): " .. uri) | |
+ end), | |
+ | |
+}, true) | |
+ | |
+------------------------------------------- | |
+-- Webview extras | |
+------------------------------------------- | |
+ | |
+-- Custom magnet: URI handlers | |
+webview.init_funcs.magnet_hook = function (view, w) | |
+ view:add_signal("navigation-request", function (v, uri) | |
+ if string.match(string.lower(uri), "^magnet:") then | |
+ luakit.spawn(string.format("%s %q", "transmission-gtk", uri)) | |
+ return false | |
+ end | |
+ end) | |
+end | |
+ | |
-- vim: et:sw=4:ts=8:sts=4:tw=80 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment