https://github.com/tkuenneth/nativeparameterstoreaccess
A small Java library to access the Windows registry, Linux dconf and macOS defaults
https://github.com/tkuenneth/nativeparameterstoreaccess
java kotlin library linux macos windows
Last synced: about 1 year ago
JSON representation
A small Java library to access the Windows registry, Linux dconf and macOS defaults
- Host: GitHub
- URL: https://github.com/tkuenneth/nativeparameterstoreaccess
- Owner: tkuenneth
- License: mit
- Created: 2020-12-23T10:48:58.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-06-04T10:21:58.000Z (about 2 years ago)
- Last Synced: 2025-03-28T11:51:08.231Z (about 1 year ago)
- Topics: java, kotlin, library, linux, macos, windows
- Language: Java
- Homepage:
- Size: 59.6 KB
- Stars: 13
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Welcome to Native Parameter Store Acess
### A small Java library to access the Windows Registry, macOS Defaults database and dconf.
Sometimes you need to access the Windows Registry, the macOS Defaults database or dconf in your Java or Kotlin apps.
While the Java standard class library includes the Preferences api to read and write app-specific values, you cannot use
it to access system settings. That's what this tiny library is for.
#### Include in your project
It is very easy to add the library to your project.
##### Maven
```xml
com.github.tkuenneth
nativeparameterstoreaccess
0.1.3
```
##### Gradle
```
dependencies {
implementation("com.github.tkuenneth:nativeparameterstoreaccess:0.1.3")
}
```
#### Examples
This Kotlin example shows how to detect if the system (macOS, Linux with dconf or Windows) is using a dark theme.
```kotlin
fun isSystemInDarkTheme(): Boolean = when {
IS_WINDOWS -> {
val result = WindowsRegistry.getWindowsRegistryEntry(
"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",
"AppsUseLightTheme")
result == 0x0
}
IS_MACOS -> {
val result = MacOSDefaults.getDefaultsEntry("AppleInterfaceStyle")
result == "Dark"
}
HAS_DCONF -> {
val result = Dconf.getDconfEntry("/org/gnome/desktop/interface/gtk-theme")
result.toLowerCase().contains("dark")
}
else -> false
}
```