Skip to content

Kotlin Multiplatform library for retrieving accent color on various targets in a simple and unified way

License

Notifications You must be signed in to change notification settings

LennyLizowzskiy/accents-kt

Repository files navigation

accents.kt

Kotlin Multiplatform library for retrieving accent color in a simple way.

Supported platforms

  • 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.

Requirements

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

Usage

Configure dependencies

  1. 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' }
        // ...
    }
}
  1. 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' 
}

How to use

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);
    }
}

About

Kotlin Multiplatform library for retrieving accent color on various targets in a simple and unified way

Resources

License

Stars

Watchers

Forks

Packages

No packages published