![]() |
#1 |
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 40
Karma: 1000
Join Date: Jun 2022
Device: Kindle Oasis
|
How to execute a .lua script in KOReader?
I’m testing how to run .lua scripts in KOReader. (installed on Paperwhite11)
I created a test file using: echo 'local _ = require("logger").info("TEST OK"); os.exit()' > /mnt/us/koreader/scripts/test.lua The file test.lua exists in /mnt/us/koreader/scripts/, but I can’t find any ‘Scripts’ menu in KOReader to execute it. How can I run this script?" Last edited by beecom; 04-10-2025 at 09:25 PM. |
![]() |
![]() |
![]() |
#2 |
cosiñeiro
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,406
Karma: 2451781
Join Date: Apr 2014
Device: BQ Cervantes 4
|
KOReader is in itself a big lua script.
It provides a way to execute your own on demand if you write a plugin. It also provides hooks that get called automatically and are useful to write your own user patches. Both patches and plugins are executed on the same vm as ko does, so issuing os.exit it isn't going to exit your script but the whole program. |
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 40
Karma: 1000
Join Date: Jun 2022
Device: Kindle Oasis
|
Quote:
I was wondering if there's a way to add a script (which is not directly related to KOReader) into KOReader's menu so that I can see and run it from there. What I'm trying to do is have a script stored on the Kindle that detects when the file /tmp/pc.png is updated (which is periodically refreshed from my PC), and then re-renders the screen using that updated image. I'd like to be able to trigger this script from within KOReader. |
|
![]() |
![]() |
![]() |
#4 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 135
Karma: 33084
Join Date: Jan 2021
Device: Likebook Mars
|
KOReader ships with the hello.koplugin test-plugin in the plugins/ folder. You can use that as a template to make your own. Remove the first clode block in main.lua to activate it (you may then also need to check the box to activate it in the plugin-settings) and see how it works.
To create your own, copy the hello.koplugin folder to plugins/myscript.koplugin (or whatever), and rename the script's name and menu entry in the code. Of course also add your own code to execute on pressing the new menu entry. |
![]() |
![]() |
![]() |
#5 | |
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 40
Karma: 1000
Join Date: Jun 2022
Device: Kindle Oasis
|
Quote:
I managed to get hello.koplugin to show up in the menu list, but I couldn't get my code to appear on the list despite trying several times. |
|
![]() |
![]() |
Advert | |
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to execute a bash script in koreader | madtsu | KOReader | 3 | 08-06-2024 06:52 AM |
How to execute a script on wakeup | Kindleschokolade | Kindle Developer's Corner | 0 | 01-30-2022 07:06 PM |
K3 execute script when (un)plugged | logpig | Kindle Developer's Corner | 1 | 03-07-2021 01:13 PM |
PRS-T1 Factory reset - possible to execute via script? | bookler | Sony Reader Dev Corner | 1 | 07-04-2012 12:48 PM |
Is it possible to execute a bash script from the SD card? | godel10 | iRex | 25 | 06-25-2009 03:55 PM |