{"id":15020165,"url":"https://github.com/albertosottile/darkdetect","last_synced_at":"2025-04-12T22:22:52.815Z","repository":{"id":34878907,"uuid":"186476766","full_name":"albertosottile/darkdetect","owner":"albertosottile","description":"Detect OS Dark Mode from Python","archived":false,"fork":false,"pushed_at":"2024-03-11T06:48:12.000Z","size":34,"stargazers_count":196,"open_issues_count":13,"forks_count":19,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-04T01:11:08.427Z","etag":null,"topics":["dark","dark-mode","dark-syntax-theme","dark-theme","darkmode","pyqt5","pyqt6","pyside2","pyside6","qt","tkinter","ubuntu","windows-10"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/albertosottile.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-13T18:45:50.000Z","updated_at":"2025-03-04T12:50:05.000Z","dependencies_parsed_at":"2023-01-15T09:50:56.083Z","dependency_job_id":"37d0d109-f60c-4c3b-b820-ddafc6e524ad","html_url":"https://github.com/albertosottile/darkdetect","commit_stats":{"total_commits":46,"total_committers":11,"mean_commits":4.181818181818182,"dds":"0.28260869565217395","last_synced_commit":"64ce54e20be54cc41f85c8c208d35a4137b958d3"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertosottile%2Fdarkdetect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertosottile%2Fdarkdetect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertosottile%2Fdarkdetect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albertosottile%2Fdarkdetect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/albertosottile","download_url":"https://codeload.github.com/albertosottile/darkdetect/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248638603,"owners_count":21137688,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dark","dark-mode","dark-syntax-theme","dark-theme","darkmode","pyqt5","pyqt6","pyside2","pyside6","qt","tkinter","ubuntu","windows-10"],"created_at":"2024-09-24T19:54:40.012Z","updated_at":"2025-04-12T22:22:52.738Z","avatar_url":"https://github.com/albertosottile.png","language":"Python","funding_links":[],"categories":["Tips and tricks"],"sub_categories":["Set the theme to the system theme"],"readme":"# Darkdetect\n\nThis package allows to detect if the user is using Dark Mode on:\n\n- [macOS 10.14+](https://support.apple.com/en-us/HT208976)\n- [Windows 10 1607+](https://blogs.windows.com/windowsexperience/2016/08/08/windows-10-tip-personalize-your-pc-by-enabling-the-dark-theme/)\n- Linux with [a dark GTK theme](https://www.gnome-look.org/browse/cat/135/ord/rating/?tag=dark).\n\nThe 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.\n\n\n## Usage\n\n```\nimport darkdetect\n\n\u003e\u003e\u003e darkdetect.theme()\n'Dark'\n\n\u003e\u003e\u003e darkdetect.isDark()\nTrue\n\n\u003e\u003e\u003e darkdetect.isLight()\nFalse\n```\nIt's that easy.\n\nYou 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.\n\n``` python\nimport threading\nimport darkdetect\n\n# def listener(callback: typing.Callable[[str], None]) -\u003e None: ...\n\nt = threading.Thread(target=darkdetect.listener, args=(print,))\nt.daemon = True\nt.start()\n```\n\n## Install\n\nThe preferred channel is PyPI:\n```\npip install darkdetect\n```\n\nAlternatively, you are free to vendor directly a copy of Darkdetect in your app. Further information on vendoring can be found [here](https://medium.com/underdog-io-engineering/vendoring-python-dependencies-with-pip-b9eb6078b9c0).\n\n## Optional Installs\n\nTo enable the macOS listener, additional components are required, these can be installed via:\n```bash\npip install darkdetect[macos-listener]\n```\n\n## Notes\n\n- This software is licensed under the terms of the 3-clause BSD License.\n- 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.\n- On macOS, detection of the dark menu bar and dock option (available from macOS 10.10) is not supported.\n- [Details](https://stackoverflow.com/questions/25207077/how-to-detect-if-os-x-is-in-dark-mode) on the detection method used on macOS.\n- [Details](https://askubuntu.com/questions/1261366/detecting-dark-mode#comment2132694_1261366) on the experimental detection method used on Linux.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falbertosottile%2Fdarkdetect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falbertosottile%2Fdarkdetect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falbertosottile%2Fdarkdetect/lists"}