05-17-2016, 11:04 AM | #1 |
BLAM!
Posts: 13,499
Karma: 26047188
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
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! Last edited by NiLuJe; 04-27-2024 at 01:58 PM. Reason: Bump to 1.4.7-rc |
05-17-2016, 01:24 PM | #2 |
Linux User
Posts: 2,281
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. |
Advert | |
|
05-17-2016, 01:48 PM | #3 |
BLAM!
Posts: 13,499
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. |
05-17-2016, 04:36 PM | #4 |
Linux User
Posts: 2,281
Karma: 6123806
Join Date: Sep 2010
Location: Heidelberg, Germany
Device: none
|
C isn't my primary language either.
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 |
05-18-2016, 09:18 PM | #5 | |
Pain in the arse
Posts: 758
Karma: 77856
Join Date: Apr 2013
Device: Kobo Aura One, Kindle 4
|
Quote:
|
|
Advert | |
|
05-18-2016, 10:10 PM | #6 |
BLAM!
Posts: 13,499
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. |
05-18-2016, 11:34 PM | #7 | |
Grand Sorcerer
Posts: 24,905
Karma: 47303822
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
Quote:
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. |
|
05-18-2016, 11:40 PM | #8 |
Grand Sorcerer
Posts: 12,855
Karma: 75642378
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... |
05-19-2016, 12:25 AM | #9 |
BLAM!
Posts: 13,499
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 |
05-19-2016, 09:47 AM | #10 |
cosiñeiro
Posts: 1,341
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. |
05-19-2016, 06:32 PM | #11 |
BLAM!
Posts: 13,499
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 . |
05-20-2016, 05:23 AM | #12 |
Connoisseur
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? |
05-20-2016, 10:46 AM | #13 |
Pain in the arse
Posts: 758
Karma: 77856
Join Date: Apr 2013
Device: Kobo Aura One, Kindle 4
|
|
05-20-2016, 10:53 AM | #14 |
BLAM!
Posts: 13,499
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. |
05-20-2016, 11:39 AM | #15 |
Linux User
Posts: 2,281
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
|
Tags |
fmon, kfmon, kobo, launcher |
Thread Tools | Search this Thread |
|
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 |