Skip to content

Instantly share code, notes, and snippets.

@mallomar
mallomar / 2-unified-auto-sync.lua
Last active December 6, 2025 22:37
Automatically sync Reading Statistics, Vocabulary Builder and Highlight Sync at user configurable events (e.g. open, close, suspend) - requires HighlightSync plugin (https://github.com/gitalexcampos/koreader-Highlight-Sync)
-- 2-unified-autosync.lua - KOReader Auto Sync Patch
-- Place in /storage/emulated/0/koreader/patches/
--
-- Features:
-- - Syncs Highlightsync, Statistics, and Vocabulary Builder automatically
-- - Robust Highlightsync detection with fallback (from v2.5)
-- - Global cooldown prevents double-syncing (from v2.5)
-- - Stable Vocabulary sync (from v3.2)
-- - Smart reload detection prevents infinite loops
-- - Configurable triggers (open, close, suspend)
--[[
This user patch adds a "header" into the reader display, similar to the footer at the bottom.
Modified to show: Time & Battery (left) | Author — Title (center) | R: percentage | pages (right)
Features:
- Configurable sections (easily turn on/off what appears in each area)
- Dynamic separator matching footer settings
- Battery charging indicator and icon toggle
- Smart space calculation with minimum spacing
@mallomar
mallomar / 2-anki-modify.lua
Last active September 26, 2025 18:20
Modifies the Anki plugin to export book title, chapter title and book reference page to the sentence context field (requires Anki plugin: https://github.com/Ajatt-Tools/anki.koplugin)
-- anki-modify.lua - Version that uses proper EPUB navigation for page mapping
local logger = require("logger")
logger.info("=== ANKI CONTEXT PATCH LOADING ===")
local function patch_anki_note()
local success, AnkiNote = pcall(require, "ankinote")
if not success then
logger.warn("Anki Context Patch: Could not load ankinote module")
return false
@mallomar
mallomar / 2-file-modification-warning.lua
Created September 11, 2025 19:10
Advise you if file appears to have been modified since binary checksum hash was created, which could affect syncing which depends on binary hash
--[[
KOReader Patch: File Modification Warning
Alerts when book files may have been modified since sync hash was calculated
--]]
local ConfirmBox = require("ui/widget/confirmbox")
local DocSettings = require("docsettings")
local UIManager = require("ui/uimanager")
local InfoMessage = require("ui/widget/infomessage")
local lfs = require("libs/libkoreader-lfs")
@mallomar
mallomar / 2-hardcover-highlight-modify.lua
Last active September 24, 2025 16:22
Pulls Up the Hardcover Quote Menu Immediately After Making a Highlight (Requires Hardcover.App Plugin: https://github.com/Billiam/hardcoverapp.koplugin)
-- Hardcover Auto-Quote Final Patch
-- Uses the official HardcoverNote event from plugin v0.1.3
local logger = require("logger")
local Event = require("ui/event")
local UIManager = require("ui/uimanager")
logger.info("=== HARDCOVER AUTO-QUOTE FINAL PATCH LOADING ===")
-- Hook into ReaderHighlight
@mallomar
mallomar / 2-progress-bar-colors.lua
Last active November 28, 2025 15:36
Makes All Progress Bars, Including Those in Project:Title, Green
local ProgressWidget = require("ui/widget/progresswidget")
local Blitbuffer = require("ffi/blitbuffer")
-- Progress bar colors
local PROGRESS_FILL_COLOR = Blitbuffer.colorFromString("#00AA00") -- Darker, more saturated green
local PROGRESS_BORDER_COLOR = Blitbuffer.COLOR_BLACK
local PROGRESS_BG_COLOR = Blitbuffer.COLOR_WHITE
-- Chapter icon colors
local CHAPTER_ICON_COLOR = Blitbuffer.COLOR_BLACK
local readerFooter = require("apps/reader/modules/readerfooter")
local ProgressWidget = require("ui/widget/progresswidget")
local BD = require("ui/bidi")
local Blitbuffer = require("ffi/blitbuffer")
local Geom = require("ui/geometry")
local Math = require("optmath")
local Screen = require("device").screen
-- Threshold for initial position marker
local INITIAL_MARKER_HEIGHT_THRESHOLD = Screen:scaleBySize(12)
@mallomar
mallomar / 2-add-sync-hash-isbn-metahash-to-tools-menu.lua
Last active September 24, 2025 16:24
Adds a Menu Item in Tools Showing the Book's Partial Sync Hash
--[[
KOReader Patch: Add Book Info with Both Hashes to Menu
Adds a menu item to display the book's sync hash and Readest meta hash
--]]
-- Function to find the KOReader sync hash
local function findSyncHash(file_path)
if not file_path then return nil end
local ok_ds, DocSettings = pcall(require, "docsettings")
@mallomar
mallomar / 2-chapter-title-spacing.lua
Created September 2, 2025 20:21
A patch to maximize the size of the chapter name in the status bar
-- 2-chapter-title-spacing.lua
-- Fix for chapter title truncation in footer
local logger = require("logger")
logger.info("=== CHAPTER TITLE SPACING FIX STARTING ===")
-- Wait for UI to load, then modify the footer text fitting behavior
local UIManager = require("ui/uimanager")
@mallomar
mallomar / 2-project-title-jpeg-filter.lua
Last active November 18, 2025 06:30
User patch to filter JPEG files from Project:Title Library Mode (Requires Project:Title plugin: https://github.com/joshuacant/ProjectTitle)
-- User patch to hide JPG and JPEG files in Project Title Library Mode
-- This hooks into the CoverMenuGenItemTable function as suggested by Project Title dev Joshua Cant
local function filterJPEGFiles(items)
local filtered_items = {}
for i, item in ipairs(items or {}) do
local filename = item.text or ""
local filepath = item.path or ""