diff --git a/manual/customize.rst b/manual/customize.rst index 0229e5451a..bd5206bf04 100644 --- a/manual/customize.rst +++ b/manual/customize.rst @@ -49,7 +49,7 @@ Environment variables the system theme -- beware of crashes and hangs. * ``CALIBRE_SHOW_DEPRECATION_WARNINGS`` - causes calibre to print deprecation warnings to stdout. Useful for calibre developers. * ``CALIBRE_NO_DEFAULT_PROGRAMS`` - prevent calibre from automatically registering the filetypes it is capable of handling with Windows. - * ``CALIBRE_USE_DARK_PALETTE`` - set it to ``1`` to have calibre use dark colors and ``0`` for light colors. Works on **Linux only**. + * ``CALIBRE_USE_DARK_PALETTE`` - set it to ``1`` to have calibre use dark colors and ``0`` for light colors. Overrides the system-wide dark setting. When set, changes to the colors while calibre is running will not take effect. Works on **Linux and Windows only**. * ``SYSFS_PATH`` - Use if sysfs is mounted somewhere other than /sys * ``http_proxy``, ``https_proxy`` - used on Linux to specify an HTTP(S) proxy diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index 4bc9f641f3..a15f926884 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -1229,7 +1229,10 @@ class Application(QApplication): using_calibre_style = True if using_calibre_style: if iswindows: - use_dark_palette = windows_is_system_dark_mode_enabled() + if 'CALIBRE_USE_DARK_PALETTE' in os.environ: + use_dark_palette = os.environ.get('CALIBRE_USE_DARK_PALETTE') == '1' + else: + use_dark_palette = windows_is_system_dark_mode_enabled() elif ismacos: use_dark_palette = False else: @@ -1257,6 +1260,8 @@ class Application(QApplication): @pyqtSlot(str, str, QDBusVariant) def linux_desktop_setting_changed(self, namespace, key, val): if (namespace, key) == ('org.freedesktop.appearance', 'color-scheme'): + if 'CALIBRE_USE_DARK_PALETTE' in os.environ: + return use_dark_palette = val.variant() == 1 if use_dark_palette != bool(self.is_dark_theme): if use_dark_palette: @@ -1266,6 +1271,8 @@ class Application(QApplication): self.on_palette_change() def check_for_windows_palette_change(self): + if 'CALIBRE_USE_DARK_PALETTE' in os.environ: + return use_dark_palette = bool(windows_is_system_dark_mode_enabled()) if bool(self.is_dark_theme) != use_dark_palette: if use_dark_palette: