Kotlin Multiplatform library for retrieving accent color in a simple way.
- JVM / Android
- JVM / Windows
- JVM / macOS
- JVM / Linux (GTK)
- JVM / Linux (KDE)
- JVM / Linux (FreeDesktop, dbus)
- Native / macOS
- Native / Linux
- Native / Windows
Web targets won't be supported. Check developer.mozilla/css/accent-color if you need this feature.
Also, I don't guarantee that I will be able to support Native and/or macOS targets, so PRs are always welcome.
Platform | /stuff/ |
---|---|
JVM / Windows | version 10 or higher, reg query access for the caller |
JVM / macOS | version 11 or higher, sw_vers access for the caller |
JVM / Linux (GTK3) | GTK3 config dir (_CONFIG_DIR_/gtk-3.0 ) access for the caller |
JVM / Linux (KDE) | KDE config dir (_CONFIG_DIR_/plasma-org.kde.plasma.desktop-appletsrc ) access for the caller, tested on KDE 5 |
JVM / Linux (FreeDesktop, dbus) | busctl access for the caller, XDG Desktop Portal must be installed in the system and it must support org.freedesktop.appearance.color-scheme protocol |
- Add
jitpack.io
repository in your root build.gradle
// build.gradle
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
// ...
maven { url 'https://jitpack.io' }
// ...
}
}
- Add the dependency
dependencies {
// replace RELEASE_TAG with the latest release from the Releases or Tags page
implementation 'com.github.LennyLizowzskiy:accents-kt:RELEASE_TAG'
}
or per-platform release:
dependencies {
// replace PLATFORM with the one you need (example: `library-jvm`)
implementation 'com.github.LennyLizowzskiy.accents-kt:PLATFORM:RELEASE_TAG'
}
A single line of code to get the accent color on any of the supported platforms
import com.lizowzskiy.accents.getAccentColor
val accent = getAccentColor()
Calling from Java:
import com.lizowzskiy.accents.AccentUtil;
import com.lizowzskiy.accents.Color;
public class Foo {
public void bar() {
Color accent = AccentUtil.getAccentColor();
System.out.println(accent);
}
}