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 internal 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 start with a magic identifying string, a version field, a little-endian header length, and a list of headers for each resource. Then there's a compressed section for each resource.

offset bytes value
0 15 magic identifier "PocketBookTheme"
15 1 file version - always 0x01
16 4 total size of all resource headers

Each resource header has 3 32-bit unsigned little-endian integers. The first resource (the theme configuration) has no name, but all others have NUL-terminated names. Each header is a multiple of 4 bytes in size.

offset bytes value
0 4 uncompressed size
4 4 file offset to compressed resource
8 4 compressed size
12 variable name of resource

Each resource is then separately compressed with zlib (RFC 1950)

   $ 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 try to convert them to and from Windows BMP files. However they all get the resource format wrong and write garbage. The xpbres tool can write xpm files instead. Correct image format converters are found in pbtools.

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