PocketBook Themes

From MobileRead
Jump to: navigation, search

PocketBook devices support "theming", in the sense that you can change the way the UI looks and is arranged to a great degree.

However themes aren't documented. Although PocketBook have provided a command-line tool called "pbres" to read and write theme files, it was only ever provided for Windows. Several other open source clones of this tool have since appeared which can build and run on Macs and Linux, and even Windows. Here are some that I've found:

They all work mostly the same way.

The official PocketBook SDK includes a native ARM binary of "pbres" but it is unclear what that supports. The strings suggest it was built in 2020, and the arguments are different to the Windows "pbres.exe".

[edit] Theme files

Theme files have a ".pbt" extension, and have a proprietary binary format. I will use the Line.pbt resource that ships with the Inkpad Color 3 (6.8 firmware) in the following examples. (It is in the /ebrmain/themes directory.) I will also use Enyby's pbres, because it is very easy to build.

The compiled "*.pbt" theme files have a header, a version field, an uncompressed text configuration section, and a compressed (zlib) section. All the files I've seen are version 1, even from the most recent devices.

Each file is an array of resources. The first resource is the theme configuration file. All the remaining resources have names, and some data. You can list the resources:

   $ ../pbres/pbres -l Line.pbt
   resource                 size     compressed
   --------------------------------------------
   <theme.cfg>            193900         31671
   AppStore:4              23416          2898
   CardLogo:4             248460         75326
   GooglePlay:4            25288          3020
   about:4                 15136           669
   activate_account_on_eink:4    61264           705
   activate_account_on_smartphone:4    61264          1301
   add_to_cloud:4          15136          1158
   adjustments:4           15136           168
   adjustments_inv:4       15136           801
   adobe_activation_layout:4    11342          1170
   [... lots more resources omitted ...]
   wwbishop:4              18368          2198
   wwking:4                18368          2638
   wwknight:4              18368          2396
   wwpawn:4                18368          1885
   wwqueen:4               18368          3219
   wwrook:4                18368          2009
   zoom_in:4               15136          1051
   zoom_out:4              15136          1034

In this version of Line.pbt there are over 1400 resources.

Many of the resources are images, and the appended ":4" seems to indicate their bit depth. The internal format for an image is described in the PocketBook SDK and is proprietary, however the pbres tools typically convert them to and from Windows BMP files. All the ":4" images I've seen get saved as 8bpp BMP files. NB: Macs can't read every kind of BMP file, including, it seems, these ones. I hate the BMP format. The xpbres tool can write xpm files instead.

You can extract a raw resource by name, eg "pbres -u Line.pbt wwrook:4"

You can also dump an entire theme file, eg "pbres -d Line.pbt" which will create subdirectories containing all the images converted to BMP. However! Not all resources are images, and most tools just crash if they try to convert one of these resources to BMP. An example above is "adobe_activation_layout:4". Let's unpack it and see:

   $ ../pbres/pbres -u Line.pbt adobe_activation_layout:4
   $ file adobe_activation_layout:4 
   adobe_activation_layout:4: JSON data

So not an image after all, and indeed it does look like JSON...

   {"AppLoginView" : {"class" : "PBDialog","background_color" : 16777215,"info_label" : {"class" : "PBLabel","window_pos" :
   [...]

I have also seen TrueType fonts being embedded as resources.

[edit] Config file

The "<theme.cfg>" file that's extracted has an INI file-style syntax. The one in Line.pbt is just over 5000 lines long. Nothing seems to refer to the other resources by name.

There is some translated documentation of the text configuration format in another MobileRead forum thread.

What happens if you install an old theme on a new device? Are the themes hard coded to screen sizes?

Personal tools
Namespaces

Variants
Actions
Navigation
MobileRead Networks
Toolbox