Skip to content

Instantly share code, notes, and snippets.

View sebdelsol's full-sized avatar

sebdelsol

  • Montpellier, France
  • 04:10 (UTC +02:00)
View GitHub Profile
@sebdelsol
sebdelsol / 2-reference-page-count.lua
Last active May 26, 2025 15:26
KOReader user patch: fix reference pages if missing. Gives the actual number of pages in the status bar
-- **MOVED to https://github.com/sebdelsol/KOReader.patches**
-- fallback if there's no source for reference pages
-- gives the actual number of pages in the status bar page_progress & page_left_book instead of a label
local ReaderFooter = require("apps/reader/modules/readerfooter")
local ReaderPageMap = require("apps/reader/modules/readerpagemap")
local userpatch = require("userpatch")
local footerTextGeneratorMap = userpatch.getUpValue(ReaderFooter.applyFooterMode, "footerTextGeneratorMap")
@sebdelsol
sebdelsol / 2-statusbar-better-compact.lua
Last active May 26, 2025 15:26
KOReader userpatch for better compact items status bar
-- **MOVED to https://github.com/sebdelsol/KOReader.patches**
-- enhance compact items:
-- use the better frontlight icons, and add the battery percentage
-- better separator for title/chapter/author in compact mode with no separator
local ReaderFooter = require("apps/reader/modules/readerfooter")
local userpatch = require("userpatch")
local footerTextGeneratorMap = userpatch.getUpValue(ReaderFooter.applyFooterMode, "footerTextGeneratorMap")
local symbol_prefix = userpatch.getUpValue(footerTextGeneratorMap.frontlight, "symbol_prefix")
@sebdelsol
sebdelsol / 2-change-status-bar-color.lua
Last active May 26, 2025 15:25
KOReader user patch: change status bar progress color
-- MOVED TO https://github.com/sebdelsol/KOReader.patches
-- based on https://gist.github.com/IntrovertedMage/d759ff214f799cfb5e1f8c85daab6cae
-- Menu added in the Reader menu:
-- settings > Status bar > Progress bar > Thickness, height & colors > Read color
-- settings > Status bar > Progress bar > Thickness, height & colors > Unread color
local Blitbuffer = require("ffi/blitbuffer")
local Math = require("optmath")
local ProgressWidget = require("ui/widget/progresswidget")
@sebdelsol
sebdelsol / configuration.lua
Created May 7, 2025 15:13
[assistant.koplugin] configuration.lua for gemini
local GEMINI_API_KEY = "here is my key"
local MY_LANGUAGE = "English"
local CONFIGURATION = {
-- Choose your preferred AI provider: "anthropic", "openai", "gemini", "openrouter", "deepseek" or "ollama"
provider = "gemini",
-- Provider-specific settings
provider_settings = {
anthropic = {
@sebdelsol
sebdelsol / 2-statusbar-cycle-presets.lua
Last active May 26, 2025 16:12
KOReader user patch: cycle through all the presets when tapping the status bar
-- **MOVED to https://github.com/sebdelsol/KOReader.patches**
-- NEED at least v2025-04-52 !
local ReaderFooter = require("apps/reader/modules/readerfooter")
local util = require("util")
local logger = require("logger")
local FooterCurrentPresetSetting = "footer_current_preset"
@sebdelsol
sebdelsol / 2-filemanager-title-bar.lua
Last active May 28, 2025 17:47
KOReader userpatch to show info in the file browser title with autorefresh_time
-- **MOVED to https://github.com/sebdelsol/KOReader.patches**
-- KOReader userpatch to show info in the file manager title bar
-- based on https://gist.github.com/hius07/c53bc1ed00e0490cb1a0709c5ed6e735#file-2-fm-title-info-lua
-- Menu added in the File browser menu (1st icon) to change all the settings and rearrange the items in the title bar
-- Items added: Custom text, Brightness Level, Warmth Level, Up time, Time spent awake, Time in suspend
-- Settings added: Auto refresh clock, Custom separator, Number of spaces around separator, Show wifi when disabled, Show frontlight when off, Show path
-- Fix screen rotation (path was disappearing)
-- Arrange items reorders the items the menu
@sebdelsol
sebdelsol / 2-statusbar-thin-chapter.lua
Last active May 26, 2025 15:28
KOReader user patch: Thin status bar with chapter markers
-- **MOVED to https://github.com/sebdelsol/KOReader.patches**
local BD = require("ui/bidi")
local Blitbuffer = require("ffi/blitbuffer")
local Device = require("device")
local Geom = require("ui/geometry")
local Math = require("optmath")
local ProgressWidget = require("ui/widget/progresswidget")
local ReaderFooter = require("apps/reader/modules/readerfooter")
local ReaderToc = require("apps/reader/modules/readertoc")
@sebdelsol
sebdelsol / 2-screensaver-cover.lua
Last active May 26, 2025 15:28
KOReader user patch: Screensaver message do not overlap the cover & clear all widgets when the screensaver has no background
-- **MOVED to https://github.com/sebdelsol/KOReader.patches**
-- Add 4 new options @ the end of the "Sleep screen" menu :
-- Close widgets before showing the screensaver
-- Refresh before showing the screensaver
-- Message do not overlap image
-- Center image
-- By default it doesn't change the sleep screen behavior
@sebdelsol
sebdelsol / 2-screensaver-chapter.lua
Last active May 26, 2025 15:29
KOReader user patch: add chapter title and % in the screensaver message
-- **MOVED to https://github.com/sebdelsol/KOReader.patches**
-- Youd need a version >= v2025.04-12 to be able to show the screen saver's info message
local InfoMessage = require("ui/widget/infomessage")
local Math = require("optmath")
local ReaderUI = require("apps/reader/readerui")
local Screensaver = require("ui/screensaver")
local UIManager = require("ui/uimanager")
local _ = require("gettext")
@sebdelsol
sebdelsol / mitmproxy.py
Last active October 8, 2024 16:43
start mitmproxy in background programmatically
import asyncio
import threading
from typing import Any, Callable, Self
from mitmproxy import http
from mitmproxy.addons import default_addons, script
from mitmproxy.master import Master
from mitmproxy.options import Options