skillfed

darkdetect

Detect OS Dark Mode from Python

darkdetect v0.8.0 1.4M downloads/30d#3,994 on PyPI225
Permissive license BSD-3-Clause DORMANT released

What it is and what it does

Darkdetect is a lightweight, dependency-free library that queries the operating system to determine whether Dark Mode is currently active. It works on macOS 10.14+, Windows 10 1607+, and Linux systems with dark GTK themes, returning a simple boolean or string indicating the current theme. The package is designed for GUI application developers who need to adapt their interface colors to match the system theme, particularly when their GUI framework does not expose a native dark mode detection API.

The library provides three main functions: `theme()` returns the string 'Dark' or 'Light', `isDark()` and `isLight()` return booleans. It also offers a `listener()` function that runs as a daemon thread to monitor for OS theme changes and invoke a callback when the user switches modes. Because it has no external dependencies beyond the Python standard library, it can be vendored directly into applications if needed.

Use it for:

  • Adapt a Tkinter, wxPython, or PyQt GUI to match the system dark mode without relying on the GUI framework's own detection API.
  • Monitor for live theme switches and update application colors in real time via a background listener thread.
  • Conditionally load light or dark stylesheets or color palettes at application startup based on the current OS theme.
  • Build cross-platform desktop tools that respect user accessibility and appearance preferences on macOS, Windows, and Linux.
  • Vendor darkdetect into a standalone application to avoid external package dependencies while still supporting dark mode detection.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Detects whether the operating system is in Dark Mode on macOS 10.14+, Windows 10 1607+, and Linux with dark GTK themes, and optionally monitors for theme changes.

Yes, if you are building a GUI application on macOS, Windows, or Linux and need to detect or respond to the system dark mode. The package is lightweight, has no dependencies, and solves a real problem for frameworks that do not expose dark mode detection. Maintenance is dormant but the package is stable and has no known vulnerabilities; install it as a utility library rather than expecting active development.

Install

darkdetect on PyPI

pip

pip install darkdetect

uv

uv add darkdetect

poetry

poetry add darkdetect

Installing darkdetect

Before you install

Low friction: pure Python wheel with no runtime dependencies. Maintenance is dormant (last commit 2024-03-11, 1337 days since release), but the package is stable and archived status is false.

License in practice

BSD-3-Clause is permissive; you may use, modify, and distribute this package freely in commercial or open-source projects provided you include the license notice.

Quickstart

pip install darkdetect

import darkdetect

if darkdetect.isDark():
    print('Dark mode is active')
else:
    print('Light mode is active')

Verify before relying

  • Whether the macOS listener (optional install darkdetect[macos-listener]) requires additional system libraries or frameworks beyond what the base package provides.
  • Exact behavior and return values when run on unsupported OS versions or systems without dark mode support (documentation states it returns None but does not specify all edge cases).

Package facts

License BSD-3-Clause (permissive)
Python support supports the current Python release (>=3.6)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance dormant — 1,337 days since the last release
Last repo commit
First released
Downloads 1,369,936/month — #3,994 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: darkdetect-0.8.0-py3-none-any.whl

License :: OSI Approved :: BSD LicenseOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: Windows :: Windows 10Operating System :: POSIX :: LinuxProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

detect dark mode osdark theme detectionsystem dark mode pythongui dark mode listeneros theme detectionmacos windows linux dark mode
dark-mode-detectiongui-themingcross-platform

More Utilities packages