{"id":30740030,"url":"https://github.com/openmined/jupyter-dark-detect","last_synced_at":"2025-09-03T23:47:50.383Z","repository":{"id":306794536,"uuid":"1027251334","full_name":"OpenMined/jupyter-dark-detect","owner":"OpenMined","description":"detect if jupyter lab is in dark mode or not","archived":false,"fork":false,"pushed_at":"2025-07-27T16:25:51.000Z","size":28,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-02T06:48:16.058Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OpenMined.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,"zenodo":null},"funding":{"github":"openmined"}},"created_at":"2025-07-27T16:25:39.000Z","updated_at":"2025-07-28T01:29:14.000Z","dependencies_parsed_at":"2025-07-27T18:21:27.302Z","dependency_job_id":null,"html_url":"https://github.com/OpenMined/jupyter-dark-detect","commit_stats":null,"previous_names":["openmined/jupyter-dark-detect"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/OpenMined/jupyter-dark-detect","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenMined%2Fjupyter-dark-detect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenMined%2Fjupyter-dark-detect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenMined%2Fjupyter-dark-detect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenMined%2Fjupyter-dark-detect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OpenMined","download_url":"https://codeload.github.com/OpenMined/jupyter-dark-detect/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenMined%2Fjupyter-dark-detect/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273529549,"owners_count":25121828,"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","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-09-03T23:47:48.735Z","updated_at":"2025-09-03T23:47:50.373Z","avatar_url":"https://github.com/OpenMined.png","language":"Python","funding_links":["https://github.com/sponsors/openmined"],"categories":[],"sub_categories":[],"readme":"# jupyter-dark-detect\n\nDetect dark mode in Jupyter environments (Notebook, Lab, VS Code, etc.).\n\n## Installation\n\n```bash\npip install jupyter-dark-detect\n```\n\n## Usage\n\n```python\nfrom jupyter_dark_detect import is_dark\n\n# Check if Jupyter is running in dark mode\nif is_dark():\n    print(\"Dark mode is enabled!\")\n    # Use dark theme colors for visualizations\n    bg_color = \"#1e1e1e\"\n    text_color = \"#d4d4d4\"\nelse:\n    print(\"Light mode is enabled!\")\n    # Use light theme colors for visualizations\n    bg_color = \"#ffffff\"\n    text_color = \"#000000\"\n```\n\n## Features\n\n- **Multiple detection strategies** for maximum compatibility:\n  - JupyterLab theme settings files\n  - VS Code workspace and user settings\n  - JavaScript-based DOM inspection\n  - System preferences (macOS and Windows)\n  \n- **Zero configuration** - just import and use\n\n- **Lightweight** with minimal dependencies (only requires IPython)\n\n- **Cross-platform** support for JupyterLab, Jupyter Notebook, VS Code, and more\n\n## How It Works\n\nThe package tries multiple detection methods in order:\n\n1. **JupyterLab Settings**: Checks `~/.jupyter/lab/user-settings/` for theme configuration\n2. **VS Code Settings**: When running in VS Code, checks both workspace and user settings\n3. **JavaScript Detection**: Uses IPython magic to inspect the DOM for theme classes\n4. **System Preferences**: Falls back to OS-level dark mode settings on macOS and Windows\n\n## Use Cases\n\n- **Matplotlib/Plotly Visualizations**: Automatically adjust plot colors based on theme\n- **Rich Terminal Output**: Style console output to match the notebook theme\n- **Custom Widgets**: Build theme-aware Jupyter widgets\n- **Documentation**: Generate screenshots that match the user's theme\n\n## Example: Matplotlib Integration\n\n```python\nimport matplotlib.pyplot as plt\nfrom jupyter_dark_detect import is_dark\n\n# Set style based on theme\nplt.style.use('dark_background' if is_dark() else 'default')\n\n# Your plotting code\nplt.plot([1, 2, 3, 4], [1, 4, 9, 16])\nplt.title(\"Theme-Aware Plot\")\nplt.show()\n```\n\n## Example: Plotly Integration\n\n```python\nimport plotly.graph_objects as go\nfrom jupyter_dark_detect import is_dark\n\n# Create theme-aware Plotly figure\nfig = go.Figure()\nfig.add_trace(go.Scatter(x=[1, 2, 3, 4], y=[1, 4, 9, 16]))\n\n# Update layout based on theme\nif is_dark():\n    fig.update_layout(\n        template=\"plotly_dark\",\n        paper_bgcolor=\"#1e1e1e\",\n        plot_bgcolor=\"#1e1e1e\"\n    )\nelse:\n    fig.update_layout(\n        template=\"plotly_white\",\n        paper_bgcolor=\"white\",\n        plot_bgcolor=\"white\"\n    )\n\nfig.show()\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenmined%2Fjupyter-dark-detect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenmined%2Fjupyter-dark-detect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenmined%2Fjupyter-dark-detect/lists"}