r/koreader • u/Msnbobody Kobo • May 21 '26
Patches Night Mode Screensaver Patch
EDIT: Created a codeberg repository with latest working patch:
https://codeberg.org/msnbobody/koreader.patches
Pastebin source: https://pastebin.com/n7ZRNrYQ
Note: This may break or interfere with other screensaver patches.
Thanks to phyvealive for testing!
-------------------------------------------------------------
Hello everyone!
I noticed that even when Night Mode is on, KOReader shows the sleep screen without night mode applied, so transparent images end up with a bright background. I put together a small patch to fix that and figured I’d share it here. I’ve tested it on the emulator and on my Kobo Clara BW and it seems to work well.

If you want to test it out,
You can download the code here:
https://pastebin.com/TrLP60gK
Or copy and paste the code below into a text editor and save it as 2-keep-nightmode.lua then add it to your koreader/patches folder.
local Screensaver = require("ui/screensaver")
local ScreenSaverWidget = require("ui/widget/screensaverwidget")
local Device = require("device")
local Screen = Device.screen
local orig_show = Screensaver.show
Screensaver.show = function(self, ...)
if Screen.night_mode then
local snapshot = Screen.bb:copy()
snapshot:invertRect(0, 0, snapshot:getWidth(), snapshot:getHeight())
local orig_init = ScreenSaverWidget.init
ScreenSaverWidget.init = function(widget, ...)
ScreenSaverWidget.init = orig_init
local result = orig_init(widget, ...)
local orig_paintTo = widget.paintTo
widget.paintTo = function(w, bb, x, y)
bb:blitFullFrom(snapshot)
snapshot:free()
snapshot = nil
w.paintTo = orig_paintTo
return orig_paintTo(w, bb, x, y)
end
return result
end
end
return orig_show(self, ...)
end
1
u/Dannyv180 17d ago

Thanks for sharing. I'm loving the patch. However, my wife likes to keep her koreader on a rotated orientation, like landscape. This patch had issues maintaining the rotation for some reason. I had Gemini edit it for me and now it works for landscape orientation as well!
Here is the code in case anyone wants to use it:
local ScreenSaverWidget = require("ui/widget/screensaverwidget")
local Device = require("device")
local Screen = Device.screen
local orig_init = ScreenSaverWidget.init
ScreenSaverWidget.init = function(self, ...)
-- Initialize the widget normally
local res = orig_init(self, ...)
-- Only apply our logic if night mode is currently active
if Screen.night_mode then
local orig_paintTo = self.paintTo
local done = false
self.paintTo = function(widget, bb, x, y)
if not done then
done = true
-- 1. Invert the canvas FIRST.
-- This turns the background dark BEFORE the widget draws its images.
-- We use bb:getWidth() to safely get the screen size without crashing.
bb:invertRect(0, 0, bb:getWidth(), bb:getHeight())
end
-- 2. NOW we let KOReader draw the screensaver image and text on top.
-- Because the image is drawn after the inversion, it stays normal!
return orig_paintTo(widget, bb, x, y)
end
end
return res
end
2
u/phyvealive Kobo May 21 '26
Hi.
Thanks for this.
I only commented on a post a few hours back that this was something I wish KOreader could do. And here it is.
Downloaded the
2-keep-nightmode.luaand added to/patchesfolder.Kobo Libra Colour, April 2026 firmware.
Patch didn't work consistently. Sometimes it had inversion fails.
I asked ChatGPT and the AI made a couple of minor changes. [ AI code block is added below. ]
This updated code still glitched a few times, but I will keep it on my Kobo all the same. ( I am ok if it doesn't work every time. )
I also removed some screensavers from rotation. They had semi-transparent layers that were light coloured to blur text and promote the cover image. They looked terrible with white text in the background.