Most Ebook readers come with a standard easy Night Mode switch. I'm trying to figure this out in Calibre. So far, I've been able to change the app theme to use my dark System theme by creating
$ sudo nano /etc/profile.d/calibre.sh
export CALIBRE_USE_SYSTEM_THEME=1
Then
$ sudo service gdm restart
But I still need help to get the background in the Ebook Viewer darker with lighter text.
In addition to the steps in the question for making the overall app theme dark, one must apply a theme within the ebook viewer. Here's how to do that:
Save the default theme
Create the Dark theme
This way it will apply to all your ebooks, together with the app's theme. You can switch between the default and Dark theme from the Theming tab's Load button.
CSS:
I don't think a new CSS file is needed. Also, the instructions in the main answer are outdated (relating to an older version of Calibre with a different Ebook Viewer GUI), and so is the command (in the question) for the dark palette of Calibre main GUI; testing in version 4.6, it's
export CALIBRE_USE_DARK_PALETTE=1
to achieve that result — as said in comment by @meskobalazs.)In order to get dark background and light font in the Ebook viewer, just open an ebook with it (with the viewer, not with Calibre itself; or, from Calibre main, select the book and press "View" (Read books) button); then, right-click, then Preferences. Or alternatively open the book and right-click anywhere in it and click Preferences.
Then Colors
Then New scheme
Then set the colors for background and foreground (text).
Select Apply and OK.
With certain ebook documents I have seen an odd problem where the font color stayed black no matter the above settings, in which case making the background dark is not an option. In such cases some other ebook readers had the same problem (Foliate), while some could fix it (Bookworm).
As said here in relation to the font type, the CSS file inside the ebook may override the software settings, including font color. Testing that, I have extracted the epub file (it's a zip in fact; some archive managers need the
zip
extension, some can extract directly) and found an/EXTRACTED_LOCATION/OEBPS/Content/Content.css
where the linecolor:Black
appeared multiple times. Replacing that with "Gray" gives a rather dark (but readable) gray, while "#DBDBDB" gives a lighter gray. (After that change, compress the extracted files and folders back into a zip file and change that extension to epub.)But here I have found that the change can be done from inside Calibre: Convert books > Look and feel > Styling, select to convert to the same format and check "Colors" (instead of/beside "Fonts").
With release 4.6 of Calibre you can now use the
CALIBRE_USE_DARK_PALETTE=1
environment variable.The newer version of calibre 4.16 has an option in Preferences -> Colors called "override book colors" which could be used to enforce consistent colors in dark mode: Here is a snapshot. Click OK and you are all set.