{"id":15717453,"url":"https://github.com/dansoftowner/jsystemthemedetector","last_synced_at":"2025-04-12T23:39:06.007Z","repository":{"id":46335810,"uuid":"308948797","full_name":"Dansoftowner/jSystemThemeDetector","owner":"Dansoftowner","description":"Java library for detecting that the (desktop) operating system uses dark UI theme or not","archived":false,"fork":false,"pushed_at":"2024-10-24T07:29:53.000Z","size":501,"stargazers_count":216,"open_issues_count":14,"forks_count":26,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-12T23:39:01.331Z","etag":null,"topics":["desktop","java","java-library","java-native-access","javafx","jfa","jna","linux","macos","macosx","native-library","swing","windows"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Dansoftowner.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":"2020-10-31T18:36:50.000Z","updated_at":"2025-04-12T00:40:02.000Z","dependencies_parsed_at":"2024-10-24T10:21:21.261Z","dependency_job_id":"2a6bd427-bd38-4127-835f-1809ce15ccdb","html_url":"https://github.com/Dansoftowner/jSystemThemeDetector","commit_stats":{"total_commits":87,"total_committers":8,"mean_commits":10.875,"dds":0.367816091954023,"last_synced_commit":"ea2f8582ea08cd53f221b09930956f539e771d69"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dansoftowner%2FjSystemThemeDetector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dansoftowner%2FjSystemThemeDetector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dansoftowner%2FjSystemThemeDetector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dansoftowner%2FjSystemThemeDetector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dansoftowner","download_url":"https://codeload.github.com/Dansoftowner/jSystemThemeDetector/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248647255,"owners_count":21139081,"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":["desktop","java","java-library","java-native-access","javafx","jfa","jna","linux","macos","macosx","native-library","swing","windows"],"created_at":"2024-10-03T21:50:11.758Z","updated_at":"2025-04-12T23:39:05.988Z","avatar_url":"https://github.com/Dansoftowner.png","language":"Java","readme":"# jSystemThemeDetector\n\n[![](https://jitpack.io/v/Dansoftowner/jSystemThemeDetector.svg)](https://jitpack.io/#Dansoftowner/jSystemThemeDetector)\n[![GitHub last commit](https://img.shields.io/github/last-commit/Dansoftowner/jSystemthemedetector)](https://github.com/Dansoftowner/jSystemThemeDetector/commits/master)\n[![GitHub issues](https://img.shields.io/github/issues/Dansoftowner/jsystemthemedetector)](https://github.com/Dansoftowner/jSystemThemeDetector/issues)\n[![GitHub](https://img.shields.io/github/license/Dansoftowner/Jsystemthemedetector)](LICENSE)\n\nIn most modern operating systems there is a dark mode option. This library is created for detecting \nthis using java.\n\nIt can be useful for example if you want to synchronize your GUI App's look and feel with the operating system.\n\n\u003e This library is inspired by the dark-theme detection in [Intellij Idea](https://github.com/JetBrains/intellij-community).\n\n# Compatibility\nIt works on **Windows 10**, **MacOS Mojave** (or later) and even on **some Linux distributions**.\n\n# Requirements\n**Java 11 or higher**\n\n# Basic examples\n\n#### Simple detection\n```java\nfinal OsThemeDetector detector = OsThemeDetector.getDetector();\nfinal boolean isDarkThemeUsed = detector.isDark();\nif (isDarkThemeUsed) {\n    //The OS uses a dark theme\n} else {\n    //The OS uses a light theme\n}\n```\n\n#### Listening to changes\n\n```java\nfinal OsThemeDetector detector = OsThemeDetector.getDetector();\ndetector.registerListener(isDark -\u003e {\n    if (isDark) {\n        //The OS switched to a dark theme\n    } else {\n        //The OS switched to a light theme\n    }\n});\n```\n\n#### Using it with JavaFX/Swing\nIf you use the listener for changing the UI in a **JavaFX** application, make sure you use `Platform.runLater` in it:\n```java\nfinal OsThemeDetector detector = OsThemeDetector.getDetector();\ndetector.registerListener(isDark -\u003e {\n    Platform.runLater(() -\u003e {\n        if (isDark) {\n            // The OS switched to a dark theme\n        } else {\n            // The OS switched to a light theme\n        }\n    });\n});\n```\nIt's important because if you are doing JavaFX specific stuff in the listener, you should execute it on the UI thread (`JavaFX Application Thread`).\nOtherwise, you might face some serious issues.\n\nIn case of **AWT/Swing**, use `SwingUtilities.invokeLater` for the same reason:\n```java\nfinal OsThemeDetector detector = OsThemeDetector.getDetector();\ndetector.registerListener(isDark -\u003e {\n    SwingUtilities.invokeLater(() -\u003e {\n        if (isDark) {\n            // The OS switched to a dark theme\n        } else {\n            // The OS switched to a light theme\n        }\n    });\n});\n```\n\n# Using it with Gradle, Maven... etc\nIt's available on [JitPack](https://jitpack.io/#Dansoftowner/jSystemThemeDetector)!\n\nGradle example:\n```groovy\nrepositories {\n\t...\n\tmaven { url 'https://jitpack.io' }\n}\n\ndependencies {\n    implementation 'com.github.Dansoftowner:jSystemThemeDetector:3.6'\n}\n```\n\n# GUI Demo application\n\nThere is a Demo application available [here](src/test/java/GuiDemo.java). It's \na basic JavaFX application that changes the UI when the OS switched to a dark/light theme.\n\n### Linux/Ubuntu example\n![Running the demo app on Ubuntu](docs/screenshot/UbuntuThemeDetection.gif)\n\n### Windows 10 example\n![Running the demo app on Windows 10](docs/screenshot/Windows10ThemeDetection.gif)\n\n# Projects using `jSystemThemeDetector`\n\n* [Boomega](https://github.com/Dansoftowner/Boomega) - A modern book explorer \u0026 catalog application\n* [Document Archiver](https://github.com/Document-Archiver/com.sophisticatedapps.archiving.document-archiver) - Archive all your documents in a consistent way, which enables you to retrieve them later fast and easy.\n* [pearletj](https://github.com/eth3-peth/pearletj) - Cross-platform multi-chain thick wallet for Cryto-currencies\n\nIf this library is used by your project, feel free to create a PR and mention that in this section! \n\n# Used libraries\n\n - [SLF4J](http://www.slf4j.org/) - Simple Logging Facade for Java\n - [Jetbrains Annotations](https://github.com/JetBrains/java-annotations) - Annotations for JVM-based languages\n - [JNA](https://github.com/java-native-access/jna) - Java Native Access\n - [JFA](https://github.com/0x4a616e/jfa) - Java Foundation Access\n - [OSHI](https://github.com/oshi/oshi) - Operating system \u0026 hardware information\n - [Version Compare](https://github.com/G00fY2/version-compare) - Lightweight Android \u0026 Java library to compare version strings.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdansoftowner%2Fjsystemthemedetector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdansoftowner%2Fjsystemthemedetector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdansoftowner%2Fjsystemthemedetector/lists"}