Skip to content

Instantly share code, notes, and snippets.

@mason-larobina
Created December 3, 2010 03:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mason-larobina/726550 to your computer and use it in GitHub Desktop.
Save mason-larobina/726550 to your computer and use it in GitHub Desktop.
Autoscrolling script for luakit
----------------------------------------------------------------
-- Simple autoscroll script for luakit (luakit.org) --
-- Install instructions: --
-- 1. Add to rc.lua before window spawning code. --
-- 2. Or: save to $XDG_CONFIG_HOME/luakit/autoscroll.lua and --
-- add `require "autoscroll"` to your rc.lua --
----------------------------------------------------------------
local buf, key = lousy.bind.buf, lousy.bind.key
add_binds("normal", {
-- Start autoscroll with ,a
buf("^,a$", function (w) w:set_mode("autoscroll") end),
})
add_binds("autoscroll", {
-- Increase scrolling speed
key({}, "+", function (w)
w.autoscroll_timer:stop()
w.autoscroll_timer.interval = math.max(5, w.autoscroll_timer.interval - 5)
w.autoscroll_timer:start()
end),
-- Decrease scrolling speed
key({}, "-", function (w)
w.autoscroll_timer:stop()
w.autoscroll_timer.interval = w.autoscroll_timer.interval + 5
w.autoscroll_timer:start()
end),
})
new_mode("autoscroll", {
-- Start autoscroll timer
enter = function (w)
local t = timer{interval=50}
t:add_signal("timeout", function ()
w:scroll_vert("+1px")
end)
w.autoscroll_timer = t
t:start()
end,
-- Stop autoscroll timer
leave = function (w)
if w.autoscroll_timer then
w.autoscroll_timer:stop()
w.autoscroll_timer = nil
end
end,
})
@alexdantas
Copy link

Nice mode!
Just a suggestion, could you set the prompt when the mode starts?
w:set_prompt("-- AUTOSCROLL MODE --") or something like that.

@alexdantas
Copy link

As of luakit 0d5f4ab, this doesn't work.
Apparently scroll_vert is not a valid function.

I've made some changes:

  • Replaced scroll_vert for scroll
  • Added default scroll keybindings.

Link's here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment