01-16-2019, 12:55 AM | #1 |
Wizard
Posts: 1,046
Karma: 3000024
Join Date: Feb 2012
Location: Cape Canaveral
Device: Kindle Scribe
|
(Project) Drawgress Bar — KUAL extension
Dear MobileRead community,
I really miss the old full-scale progress bar. I even wrote feedback to Amazon and asked them to return it. Meanwhile I am waiting for them to take actions, I gathered some thoughts. I hope for your help! Let's finish this together Goal: to write a KUAL extension that non-intrusively draws full progress bar line with chapter marks (both level 1 and level 2) on each page turn (every-page turn script example is Showtime). By 'non-intrusive' I mean that it should be more like an overlay written as a script, rather than Java-Bytecode patch. Hoping that methods of getting book info stay the same, this extension should be compatible with future updates. Script outline is given below. I only half-finished drawing script, due to lack of experience in bash. Attached an example of such a progress bar (drawn in fbink manually) Spoiler:
For now I am really stuck with: — Getting info about current opened book — Getting pages/locations, chapters info Where do I even start? I remember that native booklet is in Java, but I don't know how to extract working values from there. |
01-16-2019, 11:47 AM | #2 |
BLAM!
Posts: 13,477
Karma: 26012492
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
A few things:
* You'll probably never be able to get the info you want from outside the framework itself. Which pretty much makes this whole thing impossible. * As for FBInk, I have a vague inkling why you're trying to use the TTF codepath while never actually really printing "text", but it probably wouldn't be portable. The internal API has rectangle drawing helpers, but they're not exposed. For something like this, I'd simply draw an "image" (i.e., a simple w*h array, as 1px = 1byte) myself and print that via the raw printing feature (you can get the screen dimensions via FBInk, c.f. -e & get_state). Pro: That'll save you the seven million refreshes you're currently not inhibiting (-b) . Con: That's an API-only feature, meaning no shell . (As for 2., that's a quirk of the linebreaking feature, a string composed only of a single space is probably considered as a viable break-point, which makes it zero-width). Last edited by NiLuJe; 01-16-2019 at 11:53 AM. |
Advert | |
|
01-16-2019, 01:40 PM | #3 |
Wizard
Posts: 1,046
Karma: 3000024
Join Date: Feb 2012
Location: Cape Canaveral
Device: Kindle Scribe
|
@NiLuJe
Thank you for input! Then, how about a little java-patch that will only print these values into an external file? I suppose JBPatch had access to all that info for drawing its own progress bar. I am currently trying to understand its source code. The reason I used TTF is that Bookerly's symbols are nicer that these of the built-in ones, I tried all of them. "The inernal API" of what exactly you mean? |
01-16-2019, 03:37 PM | #4 |
BLAM!
Posts: 13,477
Karma: 26012492
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
Dealing with Java stuff is hellish because it's obfuscated, and re-obfuscated on every FW build (which means it might differ between devices, even for the same FW "version"), even when there were no actual code changes.
This is incidentally why JBPatch stopped being maintained: maintaining the patches was becoming increasingly annoying. (I meant FBInk's internal API ). |
01-16-2019, 04:37 PM | #5 |
Wizard
Posts: 1,046
Karma: 3000024
Join Date: Feb 2012
Location: Cape Canaveral
Device: Kindle Scribe
|
@NiLuJe
thank you for clearing this out! Okay, so let's leave alone Java booklet. I am going to approach from different side: 1) I was able to find book length and its current progress in /var/local/cc.db . However, I don't know how to extract these values from shell. I read a few tutorials on sqlite, but they only allow to change values inside the database, not extract them. How can I extract them? 2) Chapters structure prorbably I can extract from mobi files themselves. This idea comes from Calibre plug-ins capability. I am thinking on something like preparation files (with chapters info) which are put next to each respective book so that the script can go and find it. 3) The only real problem for now seems to identify which book is currently open. I'll think on it after I solve first two For now I guess I should enter them manually in the script. Last edited by mergen3107; 01-16-2019 at 04:39 PM. |
Advert | |
|
01-16-2019, 05:20 PM | #6 |
Grand Sorcerer
Posts: 5,263
Karma: 98804578
Join Date: Apr 2011
Device: pb360
|
Study the SQL command named SELECT
|
01-16-2019, 06:25 PM | #7 | ||
Going Viral
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
Quote:
Quote:
See: https://www.sqlite.org/docs.html And (picture): https://www.sqlite.org/lang.html There is also both a Lua and a Java interface to the SQLite3 library. Note: As-built, the pre-installed sqlite3 can not handle the locale setting used by a (very) few of the db tables. The Lua and the Java interfaces to the SQLite3 library do not have that problem. Both NiLuJe and myself have stand-alone builds available that can handle any Unicode locale (but they are REALLY BIG files). Last edited by knc1; 01-16-2019 at 06:32 PM. |
||
01-16-2019, 10:20 PM | #8 |
BLAM!
Posts: 13,477
Karma: 26012492
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
@knc1: Yep, in my case, it's bundled with Python (on FW >= 4.x), but it is NOT symlinked, so as not to clobber the system version .
Not that I've ever had to actually use it, though . @mergen3107: 3/ The cover mode bit of the ScreenSavers hack picks it up from the cc.db (after having picked up a book open event from lipc (c.f., cover-watchdog/cover-watchdog-helper & cover-extract). |
01-16-2019, 10:53 PM | #9 |
Wizard
Posts: 1,046
Karma: 3000024
Join Date: Feb 2012
Location: Cape Canaveral
Device: Kindle Scribe
|
Thank you guys! I'll look thoroughly at these things
|
01-18-2019, 02:43 AM | #10 |
Wizard
Posts: 1,046
Karma: 3000024
Join Date: Feb 2012
Location: Cape Canaveral
Device: Kindle Scribe
|
Some updates on my investigation.
1) I used showlog -f to see what is going on with the opened book. I was able to get something like this: Code:
... 190113:223323 cvm[15492]: I ReaderInfoLog:BookInformation:book asin=f3203e96-c039-416b-aa47-9082f48637e3,file size=2200211,file last mod date=2018-11-18 18.56.26 -0500,content type=ebook,language=en/en,length=MobiPosition_ 1530687,access=2019-01-13 22.28.24 -0500,last read position=MobiSerializedPosition_ 968606 968607,isEncrypted=false,isSample=false,isNew=false,isTTSMetdataPresent=false,isTTSMetadataAllowed=true,fileExtn=mobi: ... 2) @NiLuJe, Thank you very much! I tried your part of code from 'cover'extract' about extracting sqlite entries into variable and it works. So now I can tweak my needs of fetching these pieces of data from the last opened book. Particularly I only need p_contentSize, p_percentFinished types of data. One problem I found though is that cc.db seems to be updated upon each book close, not every page turn. So now I have to think about how to properly determine current position to redraw it. 3) I used KindleUnpack plugin in Calibre to see mobi7 and mobi8 (azw3) files' contents. For mobi7 toc.ncx file easily shows file position of each TOC entry: Code:
... <navMap> <navPoint id="np_1" playOrder="1"> <navLabel> <text>Title Page</text> </navLabel> <content src="book.html#filepos241"/> </navPoint> <navPoint id="np_2" playOrder="2"> <navLabel> <text>Copyright</text> </navLabel> <content src="book.html#filepos816"/> </navPoint> <navPoint id="np_3" playOrder="3"> ... However, %book/Text/ folder contains separate files, each of which represents just another TOC entry (but it doesn't differentiate of which level). So I am thinking about two things: 1) I should give up on different TOC level indications on progress bar; 2) I can calculate very rough position of these TOC entries based on ... cumulative file sizes with respect to total file size of this folder I tried it manually by hand on Victor Hugo's 'Les Miserables' (about 2500 print pages) and it works within +/- 3% I'll try to write a little PC script (when I find enough free time) to pre-process mobi7 and mobi8 files to extract TOC entries' positions. Last edited by mergen3107; 01-18-2019 at 03:07 AM. |
01-29-2019, 05:16 AM | #11 | |
Member
Posts: 22
Karma: 10000
Join Date: Mar 2018
Location: HK
Device: KOA2
|
Another approch?
Quote:
However, one of the drawbacks is you must enable the reading progress display, so there's no way to get locations/progress from the screen directly. Let me have a try. Last edited by PromethiumL; 01-29-2019 at 05:22 AM. |
|
01-29-2019, 11:12 AM | #12 |
Wizard
Posts: 1,046
Karma: 3000024
Join Date: Feb 2012
Location: Cape Canaveral
Device: Kindle Scribe
|
Yeah, I was thinking about that method. E. g. To make a script capture all chapter numbers while I am scrolling through TOC on Kindle. But that's too straightforward
|
01-25-2020, 12:45 AM | #13 |
Wizard
Posts: 1,046
Karma: 3000024
Join Date: Feb 2012
Location: Cape Canaveral
Device: Kindle Scribe
|
I am on my way to finish this little project.
Sorry for a dumb question, but I can't declare an array in a script: Code:
#!/bin/sh vlocstep=(10 12) What am I doing wrong? I need many arrays to input chapter locations. I am trying to write a script to launch from KUAL. Should I just write everything in python? |
01-25-2020, 03:09 AM | #14 |
Evangelist
Posts: 415
Karma: 750442
Join Date: Apr 2016
Location: Italy
Device: Kindle PW3 5.8.5.0.1
|
try adding
Code:
declare -a vlocstep |
01-25-2020, 11:31 AM | #15 |
Wizard
Posts: 1,046
Karma: 3000024
Join Date: Feb 2012
Location: Cape Canaveral
Device: Kindle Scribe
|
@encol,
I tried that too, but it says that command is not found. So, I found this thread, and apparently Kindles have busybox instead of true bash. There is a compiled version of true bash that works for me for now I know it is a little old, but I hope it will work for DrawgressBar basic needs. |
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
xmahjongg for Kindle as Kual extension | Hanspeter | Kindle Developer's Corner | 86 | 12-02-2016 07:06 PM |
kual extension to open a book | shoelesshunter | Kindle Developer's Corner | 14 | 08-16-2016 12:30 PM |
Is there a Kual Extension/add-on for cloud | eduardomb | Kindle Developer's Corner | 19 | 07-08-2016 05:43 PM |
is there any KUAL extension development guide? | fangzi | Kindle Developer's Corner | 2 | 01-02-2014 10:11 AM |