[APP][NST/G] Current Book Cover Screensaver

Search This thread

nmyshkin

Recognized Contributor
Nov 21, 2013
1,990
526
6-13-21 See post #4 below for a new automatic version of the app!!

My original intention was to look into updating this project for FW 1.21 but my eyes got bigger and bigger as I realized how difficult that would probably be for me. So here's maybe the next best thing for now.

This is a manual one-touch app which extracts the record of the currently read book from readerlocal.db, selects the appropriate cover image from .docThumbs, and copies it into a folder in /media/screensavers. A short "flash" confirms the operation.

Requirements:
1. Root
2. Superuser
3. sqlite3 in /system/bin
4. the folder "CurrentBookCover" in /media/screensavers
5. Stock Library and Reader
6. Default file storage for books and docThumbs

To install:
Download sqlite.zip (thanks to Nookie!), and the apk below. Extract sqlite3 from the zip file and copy it into /system/bin. You will probably have to change permissions (give write permission to all) and then change them back. File permissions on sqlite3 should be rwx r-x r-x or CH MOD 755.

Create the folder "CurrentBookCover" in /media/screensavers. Install the app either via ADB or by copying the apk file to your Nook and installing from a file manager. Use the NST "Settings" app to select the new screensaver folder.

You can run the app at any time. Repeats on the same title will simply overwrite. My experience with this app is that it is sluggish on first run. It seems to take a long time for SuperUser to wake up and notice the request. It may seem to fail after you initially give it permission. Run it again and it should be fine--and thereafter.

Which books?
As long as side-loaded books are in the default folders (internal: /media/My Files/Books, external: /sdcard/My Files/Books) they will be fine. Sub-folders within the "Book" folders are also OK. The reason for this restriction is so that the .docThumbs folders in which the Library places the cover images will be in a predictable place. A "settings" section would be nice to allow for some leeway, but that is beyond me and, in any case, it's the stock Library app that determines where the .docThumbs folders will go.

B&N downloaded books do not have cover images in a place where they can be found (by me, anyway). The books themselves appear to reside in /data/media/B&N Downloads and are listed by code numbers, not titles. Although the app can detect the downloaded books, there is no corresponding .docThumbs folder and so no cover images. Nothing will be copied to the screensaver folder and your default image will appear instead. However, if you want a cover image you can make one of your own for the book and copy it into /media/.docThumbs (create the folder if it's not already there). The name of the file should match the code number of the book. Something like 9780062020765.jpeg or whatever.

PDFs also do not have cover images which the Library can extract. The situation is exactly the same as for B&N downloaded books. You will get your default screensaver if you run the app. If you want a cover image just be sure to give it the same name as the PDF file and place it either in /media/.docThumbs (for internal memory) or /sdcard/.docThumbs (for external memory). Of course, there will be no thumbnail in the Library no matter what.

Books transferred using Adobe Digital Editions are like books from B&N in that they are DRM protected, although the exact nature of the DRM protection is apparently different. These books end up in /media/Digital Editions as titled epub files but no cover image is either generated or can be extracted because of the DRM. A cover thumbnail is generated in /media/Digital Editions/Thumbnails but it is very low resolution and might be suitable for the Library cover image but in my experience the NST/G is not able to find it. If you manually move the epub file to a location where other books are generally stored there is no docThumb file generated and you still don't get a cover image in the Library. So....well, there is no good solution other than to manually place a cover image of your own in the screensaver folder. Alternatively, you may choose to remove the DRM protection before transferring the book (i.e., do not use ADE to transfer) and then treat it as a regular side-loaded book. Everything will then work as expected.

This is a Tasker-generated app and my personal hope (since I use Tasker on my NST) was to make a Profile that would run this routine automatically when a book was accessed in the Library, completely silent. This has proven to be something of a puzzle as it's not clear exactly when the database is actually updated and attempts to make the task watch for that event have not been successful. Yet. I welcome any insights into that. I've never seen the app fail to pick up the correct cover.

Please report bugs/problems/suggestions.

This app--and all Tasker-generated apps--have a dependency on two library files normally installed with GApps. You can still use these apps by copying the two attached files into the locations shown below (the xml file is zipped so you can download it rather than view it):

/system/etc/permissions/com.google.android.maps.xml
/system/framework/com.google.android.maps.jar

Set permissions for both files to rw-r--r-- and reboot.
 

Attachments

  • sqlite.zip
    13.6 KB · Views: 89
  • Set_Cover.2.apk
    682.9 KB · Views: 87
  • com.google.android.maps.zip
    671 bytes · Views: 12
  • com.google.android.maps.jar
    165.1 KB · Views: 10
Last edited:
N

NOOK!E

Guest
Very nice job, @nmyshkin! I will be testing this within the next several days and will most likely post again with bugs/feedback. :)
 

nmyshkin

Recognized Contributor
Nov 21, 2013
1,990
526
Dear nmyshkin!
Do you know how to stop Nook from creating .docThumbs?
I got rid of stock Reader and Library, so I don't really need that folder. Also all my books are in internal storage (thanks to partition resize) and now it is crucial to free up more space.

The short answer is "no". The longer answer starts with "how much space could an empty folder take?" and then:

Are you still storing your books in the default (internal) folder (/My Files/Books)? The reason I ask this is that when I was working on the SetCover app I originally had no books in the internal default folder and the .docThumbs folder did not exist (unlike on the SDCard where I had all my books in the default folder there and the .docThumbs folder came into existence without me creating it). I did have some "free Friday" downloaded books in internal memory but they do not generate .docThumbs.

So my point is that I actually had to create a .docThumbs folder in the internal space just so I could test my SetCover app. My guess is that if you don't have to store your books in /My Files/Books and you put them somewhere else, no .docThumbs will be generated. I would have guessed that this is a background task of the Library when it scans the folder but if you say you have removed the Library then it must occur in some other way.

Just try one book in a different folder (if however you are accessing the books will allow that) and see if the cover image shows up in .docThumbs.
 

nmyshkin

Recognized Contributor
Nov 21, 2013
1,990
526
6-24-23: Updated to version 3.1
--removed dependency on Screenshot Easy (you can uninstall it)
--added small binary file, fb2png, to replace malfunctioning native screenshot binary


Some years have passed since I created the original app. It works fine, but I've always wished it could be automatic like some of the non-B&N readers (Cool Reader, AlReader). So with a little more knowledge and foolhardiness I returned to the project I referenced in the original post. I sorted out the patches to the old FW 1.10 and applied them to FW 1.2.2. Then I got stuck at the Settings .apk because of the signature issue. The OP never disclosed how he got around that issue, but I could not.

[nmyshkin thinks...]

I went back to my original app and reviewed the problem. What I found was that while the database files are open when a book is being read, they do not appear to be updated unless the reader is "closed" (i.e., no longer the focused window). So how to trigger the cover extraction without constantly scanning the system....

Eventually I abandoned the databases when I came up with a much simpler idea.

The cover extraction routine is triggered by exiting the Library and opening the selected book in the Reader. Actually, there is a ten-second wait time in case there is some kind of delay in opening the book or the file is very large. After 10 seconds, if the ReaderActivity is in focus the system is queried for open epub files:

Code:
#lsof | grep epub

The resulting string contains all the information needed to locate the book, and a bit of slicing and dicing yields a suitable string to locate the correct image file in .docThumbs. The image is then copied to the folder /media/screensavers/CurrentBookCover. If you have entered and left the Library without selecting a book to view then the process stops and there is no update to the screensaver image. If you select a book by some other method (via a file manager, for example) the routine will not be activated.

The app works for any side-loaded books (internal or external, in any directory), assuming you are using the stock Library and Reader. It won't work for any other books such as public library books transferred with ADE, PDFs, or books purchased from B&N. This is because the B&N software does not extract cover images from these kinds of files to place in .docThumbs. Based on my reading of the original project that got me started on this, that was also the case with that mod. If there is no cover image available, your default screensaver image will show.

A kind of solution

This version of the app includes the ability to take a screenshot manually. That means you can take a screenshot of the cover that might be displayed when you open one of the non-compliant books in the Reader (or even a book open in the Kindle app, etc.). It's not perfect and results vary depending on how the cover is displayed. If you have a gallery app like Quick Pic installed you can use it to crop the image to your liking. Of course, you can always get your own cover image elsewhere and place it in /media/screensavers/CurrentBookCover. I should add that this ability extends beyond book covers. Any displayed screen can be copied and the image will be placed in the folder. That might be useful.

Installation and setup

1. Create the directories: sdcard/Pictures/Screenshots (if not already existing) and /media/screensavers/CurrentBookCover
2. In the Nook Settings app select "CurrentBookCover" as the screensaver directory.
3.From the zip below, copy fb2png to /data/local, set permission to rwx rx rx
4. Download and install the Set Cover app (below). This is a Tasker-created app and requires the presence of two small files, included in the zip. Without these files present the app will not install! If you already have one of my other Tasker apps, you can discard the files. Otherwise copy the two included files into the locations shown below:

/system/etc/permissions/com.google.android.maps.xml
/system/framework/com.google.android.maps.jar

Set permissions for both files to rw-r--r-- and reboot. Then install the Set Cover app.

The app requires root. I have set it up so that on first run it does something trivial that requires root so that it will trigger SU and ask for permission. Once that's out of the way, subsequent taps on the app icon will take a screenshot. Of course that's not very helpful since you can't get to the app to tap when you're looking at a book cover in the Reader! You can set a hardware button (regular or long press) to the app using NookTouch ModManager. That way you can do a manual screen capture no matter where you are in the system.
 

Attachments

  • Set Cover.zip
    847.1 KB · Views: 7
Last edited:
  • Like
Reactions: memnochlv

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    6-24-23: Updated to version 3.1
    --removed dependency on Screenshot Easy (you can uninstall it)
    --added small binary file, fb2png, to replace malfunctioning native screenshot binary


    Some years have passed since I created the original app. It works fine, but I've always wished it could be automatic like some of the non-B&N readers (Cool Reader, AlReader). So with a little more knowledge and foolhardiness I returned to the project I referenced in the original post. I sorted out the patches to the old FW 1.10 and applied them to FW 1.2.2. Then I got stuck at the Settings .apk because of the signature issue. The OP never disclosed how he got around that issue, but I could not.

    [nmyshkin thinks...]

    I went back to my original app and reviewed the problem. What I found was that while the database files are open when a book is being read, they do not appear to be updated unless the reader is "closed" (i.e., no longer the focused window). So how to trigger the cover extraction without constantly scanning the system....

    Eventually I abandoned the databases when I came up with a much simpler idea.

    The cover extraction routine is triggered by exiting the Library and opening the selected book in the Reader. Actually, there is a ten-second wait time in case there is some kind of delay in opening the book or the file is very large. After 10 seconds, if the ReaderActivity is in focus the system is queried for open epub files:

    Code:
    #lsof | grep epub

    The resulting string contains all the information needed to locate the book, and a bit of slicing and dicing yields a suitable string to locate the correct image file in .docThumbs. The image is then copied to the folder /media/screensavers/CurrentBookCover. If you have entered and left the Library without selecting a book to view then the process stops and there is no update to the screensaver image. If you select a book by some other method (via a file manager, for example) the routine will not be activated.

    The app works for any side-loaded books (internal or external, in any directory), assuming you are using the stock Library and Reader. It won't work for any other books such as public library books transferred with ADE, PDFs, or books purchased from B&N. This is because the B&N software does not extract cover images from these kinds of files to place in .docThumbs. Based on my reading of the original project that got me started on this, that was also the case with that mod. If there is no cover image available, your default screensaver image will show.

    A kind of solution

    This version of the app includes the ability to take a screenshot manually. That means you can take a screenshot of the cover that might be displayed when you open one of the non-compliant books in the Reader (or even a book open in the Kindle app, etc.). It's not perfect and results vary depending on how the cover is displayed. If you have a gallery app like Quick Pic installed you can use it to crop the image to your liking. Of course, you can always get your own cover image elsewhere and place it in /media/screensavers/CurrentBookCover. I should add that this ability extends beyond book covers. Any displayed screen can be copied and the image will be placed in the folder. That might be useful.

    Installation and setup

    1. Create the directories: sdcard/Pictures/Screenshots (if not already existing) and /media/screensavers/CurrentBookCover
    2. In the Nook Settings app select "CurrentBookCover" as the screensaver directory.
    3.From the zip below, copy fb2png to /data/local, set permission to rwx rx rx
    4. Download and install the Set Cover app (below). This is a Tasker-created app and requires the presence of two small files, included in the zip. Without these files present the app will not install! If you already have one of my other Tasker apps, you can discard the files. Otherwise copy the two included files into the locations shown below:

    /system/etc/permissions/com.google.android.maps.xml
    /system/framework/com.google.android.maps.jar

    Set permissions for both files to rw-r--r-- and reboot. Then install the Set Cover app.

    The app requires root. I have set it up so that on first run it does something trivial that requires root so that it will trigger SU and ask for permission. Once that's out of the way, subsequent taps on the app icon will take a screenshot. Of course that's not very helpful since you can't get to the app to tap when you're looking at a book cover in the Reader! You can set a hardware button (regular or long press) to the app using NookTouch ModManager. That way you can do a manual screen capture no matter where you are in the system.