Created
January 23, 2023 14:25
-
-
Save aidanholm/0e17a4a418e377dc6fb257e5e854a4dc to your computer and use it in GitHub Desktop.
nightmode.lua
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
--- Night mode. | |
-- | |
-- @module nightmode | |
-- @copyright 2016 Aidan Holm | |
local stylesheet = require("stylesheet") | |
local webview = require("webview") | |
local window = require("window") | |
local add_binds = require("modes").add_binds | |
local _M = {} | |
--- Whether to enable night mode. | |
-- @readonly | |
_M.enable = false | |
local nightmode_stylesheet = stylesheet{ source = [===[ | |
* { | |
color: #aaa !important; | |
background: #050505 !important; | |
} | |
]===] } | |
webview.add_signal("init", function (view) | |
view:add_signal("stylesheet", function (v) | |
v.stylesheets[nightmode_stylesheet] = _M.enable | |
end) | |
end) | |
add_binds("normal", { | |
{ ",tn", "Toggle night-time mode.", function (w) | |
_M.enable = not _M.enable | |
for _, ww in pairs(window.bywidget) do | |
for _, v in pairs(ww.tabs.children) do | |
v.stylesheets[nightmode_stylesheet] = _M.enable | |
end | |
end | |
w:notify(string.format("%sabled night-time mode", _M.enable and "En" or "Dis")) | |
end }, | |
}) | |
return _M | |
-- 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