New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

darkdetect

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

darkdetect

Detect OS Dark Mode from Python

  • 0.8.0
  • PyPI
  • Socket score

Maintainers
1

Darkdetect

This package allows to detect if the user is using Dark Mode on:

  • macOS 10.14+
  • Windows 10 1607+
  • Linux with a dark GTK theme.

The main application of this package is to detect the Dark mode from your GUI Python application (Tkinter/wx/pyqt/qt for python (pyside)/...) and apply the needed adjustments to your interface. Darkdetect is particularly useful if your GUI library does not provide a public API for this detection (I am looking at you, Qt). In addition, this package does not depend on other modules or packages that are not already included in standard Python distributions.

Usage

import darkdetect

>>> darkdetect.theme()
'Dark'

>>> darkdetect.isDark()
True

>>> darkdetect.isLight()
False

It's that easy.

You can create a dark mode switch listener daemon thread with darkdetect.listener and pass a callback function. The function will be called with string "Dark" or "Light" when the OS switches the dark mode setting.

import threading
import darkdetect

# def listener(callback: typing.Callable[[str], None]) -> None: ...

t = threading.Thread(target=darkdetect.listener, args=(print,))
t.daemon = True
t.start()

Install

The preferred channel is PyPI:

pip install darkdetect

Alternatively, you are free to vendor directly a copy of Darkdetect in your app. Further information on vendoring can be found here.

Optional Installs

To enable the macOS listener, additional components are required, these can be installed via:

pip install darkdetect[macos-listener]

Notes

  • This software is licensed under the terms of the 3-clause BSD License.
  • This package can be installed on any operative system, but it will always return None unless executed on a OS that supports Dark Mode, including older versions of macOS and Windows.
  • On macOS, detection of the dark menu bar and dock option (available from macOS 10.10) is not supported.
  • Details on the detection method used on macOS.
  • Details on the experimental detection method used on Linux.

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc