Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > KOReader

Notices

Reply
 
Thread Tools Search this Thread
Old 04-10-2025, 09:23 PM   #1
beecom
Enthusiast
beecom can extract oil from cheesebeecom can extract oil from cheesebeecom can extract oil from cheesebeecom can extract oil from cheesebeecom can extract oil from cheesebeecom can extract oil from cheesebeecom can extract oil from cheesebeecom can extract oil from cheese
 
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.
beecom is offline   Reply With Quote
Old 04-11-2025, 10:37 AM   #2
pazos
cosiñeiro
pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.
 
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.
pazos is offline   Reply With Quote
Advert
Old 04-13-2025, 08:50 PM   #3
beecom
Enthusiast
beecom can extract oil from cheesebeecom can extract oil from cheesebeecom can extract oil from cheesebeecom can extract oil from cheesebeecom can extract oil from cheesebeecom can extract oil from cheesebeecom can extract oil from cheesebeecom can extract oil from cheese
 
Posts: 40
Karma: 1000
Join Date: Jun 2022
Device: Kindle Oasis
Quote:
Originally Posted by pazos View Post
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.
Thanks for your reply.
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.
beecom is offline   Reply With Quote
Old 04-14-2025, 04:24 AM   #4
jonnyl
Zealot
jonnyl is generous with chocolatejonnyl is generous with chocolatejonnyl is generous with chocolatejonnyl is generous with chocolatejonnyl is generous with chocolatejonnyl is generous with chocolatejonnyl is generous with chocolatejonnyl is generous with chocolatejonnyl is generous with chocolatejonnyl is generous with chocolatejonnyl is generous with chocolate
 
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.
jonnyl is offline   Reply With Quote
Old 04-14-2025, 10:06 AM   #5
beecom
Enthusiast
beecom can extract oil from cheesebeecom can extract oil from cheesebeecom can extract oil from cheesebeecom can extract oil from cheesebeecom can extract oil from cheesebeecom can extract oil from cheesebeecom can extract oil from cheesebeecom can extract oil from cheese
 
Posts: 40
Karma: 1000
Join Date: Jun 2022
Device: Kindle Oasis
Quote:
Originally Posted by jonnyl View Post
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.
I think I’ve figured out how to run my code in KOReader. Thank you for your help, jonnyl.
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.
beecom is offline   Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 07:12 AM.


MobileRead.com is a privately owned, operated and funded community.