Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Kobo Reader > Kobo Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 05-17-2016, 11:04 AM   #1
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
Posts: 13,497
Karma: 26047188
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
Post Kute File Monitor: A smarter file-trigger based launcher

The idea of building a better fmon has come up a few times, with the main goal of avoiding potential catch-22 issues by making sure an icon has been processed by nickel before launching anything...

This came up once again in a KOReader enhancement request, this time with a POC.

Since I don't use KSM, and I've always been interested in the trick used by fmon to launch stuff (using inotify, which I'm familiar with, especially how to deal with it in the peculiar environment of an USBMS device), I decided to take the plunge and build a proper, polished product out of that concept.

So here comes KFMon! The goal is to basically do what fmon does, but safer, more user-friendly, and more configurable.

Of particular interest to document readers is the ability to inhibit the launch of *anything* through KFMon while a specific action is running (that's in addition to the general protection against running concurrent instances of the same action). This feature is enabled in the KOReader & Plato configs featured in the repo .

Speaking of KOReader & Plato, if that's what you're trying to run, see the One Click Packages thread .

I won't be rehashing the documentation here, see the GitHub project for the full and up-to-date version .
This documentation includes install instruction (notice how I'm not repeating those here, so you will *have* to read the doc? ;p).

Some quick but important notes: make sure you have full backups of your device beforehand, in particular your Nickel database & settings.
Full disclosure: I never had to resort to something more drastic than a pinhole reboot & a db & settings restore (i.e; no lost content, no factory reset) during my early tests, but those Kobos sure are finicky, so, better be safe than sorry .

It ships with a default config file providing a KOReader launch icon. In order for it not to do anything stupid, it requires a current version of KOReader.

Of course, running both fmon & kfmon in parallel is highly discouraged. Thankfully, unless you're doing something wrong, you actually can't .

If you encounter anything weird, detailed feedback will be key to fix potential issues .
And, as usual, I'm open to all kind of trivial comments. In particular if you feel the documentation is lacking or confusing, don't hesitate to tell me .

And, it bears repeating: carefully read the full documentation from top to bottom before diving blindly into stuff .

NOTE: macOS users, you may have to bypass a few of your OS's most dubious "Quality of Life" features to get things to work properly, c.f., this post for more details.

Enjoy!
Attached Files
File Type: zip KFMon-v1.4.6-66-ga63e9af.zip (903.5 KB, 2813 views)
File Type: zip KFMon-Uninstaller.zip (1.7 KB, 1538 views)

Last edited by NiLuJe; 04-27-2024 at 01:58 PM. Reason: Bump to 1.4.7-rc
NiLuJe is offline   Reply With Quote
Old 05-17-2016, 01:24 PM   #2
frostschutz
Linux User
frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.
 
frostschutz's Avatar
 
Posts: 2,279
Karma: 6123806
Join Date: Sep 2010
Location: Heidelberg, Germany
Device: none
Very nice! (never could find the source code of the original fmon)

You could also work with visual cues, since nickel is going to display the image after all. If it actually appears on screen there should be no doubt left that it wasn't just a background database update or some other script fiddling with your files...

For example if the PNG image had to contain some bright pink pixels you could check the framebuffer whether or not such pixels are present, similar to how scanline detects sleep/shutdown messages in my screensaver mod.

Taking this idea further, maybe you could also put a menu / touchable buttons in the PNG itself.

eInk is black&white but the framebuffer is actually color (RGB565) so a lot could be done with color codes (and should survive image scaling) that do not necessarily alter the appearance on the eInk screen.
frostschutz is offline   Reply With Quote
Advert
Old 05-17-2016, 01:48 PM   #3
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
Posts: 13,497
Karma: 26047188
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
@frostschutz: Thanks! That's certainly an interesting idea...

Afraid it might be a tad above my pay grade (I'm not actually a CS student at all, more of an English lit one, so I'm basically terrible at C ;p), but a neat idea .

If I ever find some time/motivation, one utility I'd like to do is a simple (i.e., no Qt) tool to print text messages to the framebuffer (for those familiar with it, we have eips on Kindles, and it's damn useful).
For instance, right now, hitting a SQL busy timeout can be a bit mystifying, since there's zero actual feedback besides the action not launching :/.

Last edited by NiLuJe; 05-17-2016 at 03:08 PM.
NiLuJe is offline   Reply With Quote
Old 05-17-2016, 04:36 PM   #4
frostschutz
Linux User
frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.
 
frostschutz's Avatar
 
Posts: 2,279
Karma: 6123806
Join Date: Sep 2010
Location: Heidelberg, Germany
Device: none
Quote:
Originally Posted by NiLuJe View Post
I'm basically terrible at C ;p
C isn't my primary language either.

Quote:
Originally Posted by NiLuJe View Post
tool to print text messages to the framebuffer
I wanted to add such things to my pngshow program (which currently only does transparency, I wanted it to do offsets, delays, and other scripting) but well, takes time and motivation to find...

So those mods of mine which do give feedback on screen do this in a very primitive fashion (scanline debug mode drawing a line on screen, autoshelf having a autoshelf icon flashing on and off in lieu of a progress bar, magic memory upgrade even just blanking the screen...).

Not sure how much Kobo development I'll be doing this year or the next for that matter in the end it's a device for just reading and it does that fine
frostschutz is offline   Reply With Quote
Old 05-18-2016, 09:18 PM   #5
Lucas Malor
Pain in the arse
Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.
 
Lucas Malor's Avatar
 
Posts: 758
Karma: 77856
Join Date: Apr 2013
Device: Kobo Aura One, Kindle 4
Quote:
given the intricacies of how Nickel actually processes books, it might trigger an action before the trigger file has successfully been processed by Nickel [...] KFMon tries to alleviate this issue by doing a number of checks before deeming that launching the action is "safe": we first check if the file in question is even in the Library database, and then we confirm that it has been processed further by checking for the existence of the various thumbnails Nickel creates when first displaying a book in its Library and Homescreen.
Do you mean that Nickel should display the book icon before its processing is finished?
Lucas Malor is offline   Reply With Quote
Advert
Old 05-18-2016, 10:10 PM   #6
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
Posts: 13,497
Karma: 26047188
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
@Lucas Malor: At the very least in terms of thumbnails processing, yes. And since Nickel has to actually open the source file to process the thumbnail, that's a hit for fmon/kfmon.

Note that this is the behavior I noted on current FW versions (i.e., it does that on demand: library thumbnails are generated for the current page you're browsing in the Library, and the "last book opened" tile is generated when it has to be shown, the first time you close a new book). Nickel might have been doing some more aggressive stuff before, which might have triggered more bizarre behavior.
Or not. (After all, a number of people have been using fmon without encountering significant issues).


In any case, not treating those spurious hits as actual user-triggered opens is saner and safer.
As is not launching something that will potentially kill Nickel while Nickel has a hold on the DB, since we have no real way of knowing if Kobo bothered to fully gracefully handle SIGTERMs, since that should allegedly never happen on a vanilla production device.

And as the sickel fiasco showed, they work in mysterious ways...

Last edited by NiLuJe; 05-18-2016 at 10:17 PM.
NiLuJe is offline   Reply With Quote
Old 05-18-2016, 11:34 PM   #7
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303822
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by NiLuJe View Post
@Lucas Malor: At the very least in terms of thumbnails processing, yes. And since Nickel has to actually open the source file to process the thumbnail, that's a hit for fmon/kfmon.

Note that this is the behavior I noted on current FW versions (i.e., it does that on demand: library thumbnails are generated for the current page you're browsing in the Library, and the "last book opened" tile is generated when it has to be shown, the first time you close a new book). Nickel might have been doing some more aggressive stuff before, which might have triggered more bizarre behavior.
Or not. (After all, a number of people have been using fmon without encountering significant issues).
A very long time ago, the firmware generated all four cover images when the book was first added to the device. And it also generated and saved cover images for books on the external SD card. For sideloaded books, this was done during the book processing phase after disconnecting from the PC. Then, still a long time ago, but not quite so long, Kobo changed to generate the cover images as needed. And not to save the cover images for books on the external SD card (thought there is at least one firmware version that did). And changed where the cover images were stored. This has been the case for at least two years.

I am pretty sure that fmon was originally written during the first phase. That would have meant that fmon, or whatever called it, was not active at the point that the books were opened to generate the cover images.

Note: When reading this post, make the browser window very narrow, tilt the screen away from you and scroll the text just a little to fast to read easily. If your brain doesn't supply the correct theme music, hand in your nerd card.
davidfor is offline   Reply With Quote
Old 05-18-2016, 11:40 PM   #8
PeterT
Grand Sorcerer
PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.
 
PeterT's Avatar
 
Posts: 12,746
Karma: 75000002
Join Date: Nov 2007
Location: Toronto
Device: Libra H2O, Libra Colour
I HEARD THE MUSIC!!!!

But maybe this post should have been made on May 4th...
PeterT is offline   Reply With Quote
Old 05-19-2016, 12:25 AM   #9
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
Posts: 13,497
Karma: 26047188
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
@davidfor: Easy mark, I recently attended a John Williams tribute concert ;p.

Thanks for the Nickel history lesson though . And for keeping part of it alive in the Calibre Kobo driver, that was obviously massively helpful when working on this
NiLuJe is offline   Reply With Quote
Old 05-19-2016, 09:47 AM   #10
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,325
Karma: 2200073
Join Date: Apr 2014
Device: BQ Cervantes 4
Tested here! Worked really nice even on corner cases (adding some new watches in a row with png triggers/ proccesing huge KoboRoot.tgz files...)

I replaced fmon in my two kobo auras hd, modify the ini file to restart nickel instead of rebooting. So far so good!

I must say that my nickel DB is almost empty, as I use koreader as my main reader and keep the books outside nickel processing.


The only way I found to broke it is running lighttpd & php, with h5ai serving /mnt/onboard. h5ai has preview options for png files and this will trigger kfmon once for each watch. So, in my case this will trigger koreader, coolreader and usbnet-toggle, and of course, this breaks the system.

The solution for me is really simple, modify root of webserver to /mnt/onboard/.ebooks and put the (watched) files on /mnt/onboard.
pazos is offline   Reply With Quote
Old 05-19-2016, 06:32 PM   #11
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
Posts: 13,497
Karma: 26047188
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
@pazos: Great, thanks for the feedback (in particular the Nickel restart thing we discussed on GH, thanks .).

As for the web server thing, yeah, I'm afraid there's not much else that could be done. Inotify doesn't provide us with any information about who/what triggered the file access, so, no possibility to single out nickel .
NiLuJe is offline   Reply With Quote
Old 05-20-2016, 05:23 AM   #12
the_doc
Connoisseur
the_doc , Klaatu Barada Niktu!the_doc , Klaatu Barada Niktu!the_doc , Klaatu Barada Niktu!the_doc , Klaatu Barada Niktu!the_doc , Klaatu Barada Niktu!the_doc , Klaatu Barada Niktu!the_doc , Klaatu Barada Niktu!the_doc , Klaatu Barada Niktu!the_doc , Klaatu Barada Niktu!the_doc , Klaatu Barada Niktu!the_doc , Klaatu Barada Niktu!
 
the_doc's Avatar
 
Posts: 52
Karma: 5392
Join Date: Sep 2013
Device: Hanlin v3; Kobo Mini
I don't use KSM at all and I use fmon to start both KOReader and PBChess.
Has anyone tested this kfmon with PBChess?
the_doc is offline   Reply With Quote
Old 05-20-2016, 10:46 AM   #13
Lucas Malor
Pain in the arse
Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.
 
Lucas Malor's Avatar
 
Posts: 758
Karma: 77856
Join Date: Apr 2013
Device: Kobo Aura One, Kindle 4
Quote:
Originally Posted by NiLuJe View Post
we have no real way of knowing if Kobo bothered to fully gracefully handle SIGTERMs
Can't you send SIGSTOP?
Sometimes I lost cover files. KOReader should not boot anymore this way.
Lucas Malor is offline   Reply With Quote
Old 05-20-2016, 10:53 AM   #14
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
Posts: 13,497
Karma: 26047188
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
@Lucas Malor: I *think* there's an issue of Nickel holding exclusive access to the input devices which prevents us from using SIGSTOP, but I *might* be mixing stuff up (since that's used in various fun & interesting ways on Kindles).

EDIT: I was half-right ;p. We get the touch input, but Nickel holds an exclusive lock on the power/light buttons.
That's still an interesting possibility to speed up debugging sessions, though...

----

I'll probably open up the wiki on the GH page to let people add common watch configs, that should make it easier for people to try and migrate.

Last edited by NiLuJe; 05-20-2016 at 11:38 AM.
NiLuJe is offline   Reply With Quote
Old 05-20-2016, 11:39 AM   #15
frostschutz
Linux User
frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.
 
frostschutz's Avatar
 
Posts: 2,279
Karma: 6123806
Join Date: Sep 2010
Location: Heidelberg, Germany
Device: none
nickel does open touch input exclusively, but you can patch it... it's a string somewhere, something=1 to something=0, i don't remember... however nickel might be confused and crash on resume... also display rotation must be the same... also there is sickel the evil rebooter if nickel does not appear to be working... it got disabled finally but how long will that last
frostschutz is offline   Reply With Quote
Reply

Tags
fmon, kfmon, kobo, launcher


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help converting file from HTML>EPub. File is divided in several pages I want to merge leito360 Conversion 6 02-19-2016 01:31 PM
table of content file link not add in toc.ncx file bhambhu Conversion 0 01-14-2016 02:40 AM
FILE. Program to identify a file's format by scanning binary data for known patterns. twobob Kindle Developer's Corner 3 05-13-2013 01:59 PM
AZW2 based launcher for K3 jmseight Kindle Developer's Corner 4 04-02-2012 08:53 AM
Opus Updating EPUB file won't change publisher data on file listing spaze Bookeen 1 03-08-2011 02:34 AM


All times are GMT -4. The time now is 07:32 PM.


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