Skip to content

Commit

Permalink
Switch from ~/.skiko directory to OS-specific locations (%LOCALAPPDAT…
Browse files Browse the repository at this point in the history
…A%, $XDG_DATA_HOME etc.)
  • Loading branch information
62832 committed Mar 24, 2024
1 parent 4f22664 commit 29ae1d2
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions skiko/src/jvmMain/kotlin/org/jetbrains/skiko/SkikoProperties.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jetbrains.skiko

import java.lang.System.getenv
import java.lang.System.getProperty

// TODO maybe we can get rid of global properties, and pass SkiaLayerProperties to Window -> ComposeWindow -> SkiaLayer
Expand Down Expand Up @@ -29,8 +30,22 @@ object SkikoProperties {
* The path where to store data files.
*
* It is used for extracting the Skiko binaries (if `libraryPath` isn't null) and logging.
*
* TODO: Use $XDG_STATE_HOME (Unix) / ~/Library/Logs (macOS) for logging instead?
*/
val dataPath: String get() = getProperty("skiko.data.path") ?: "${getProperty("user.home")}/.skiko/"
val dataPath: String get() {
return getProperty("skiko.data.path") ?: when (hostOs) {
OS.Windows -> "${getenv("LOCALAPPDATA")}/Skiko"
OS.MacOS, OS.Ios -> "${getProperty("user.home")}/Library/Application Support/Skiko"
else -> {
var dataHome = getenv("XDG_DATA_HOME")
if (dataHome == null || !dataHome.startsWith('/')) {
dataHome = "${getProperty("user.home")}/.local/share"
}
return "${dataHome}/skiko"
}
}
}

val vsyncEnabled: Boolean get() = getProperty("skiko.vsync.enabled")?.toBoolean() ?: true

Expand All @@ -54,7 +69,7 @@ object SkikoProperties {
val fpsLongFramesMillis: Double? get() = getProperty("skiko.fps.longFrames.millis")?.toDouble()

val renderApi: GraphicsApi get() {
val environment = System.getenv("SKIKO_RENDER_API")
val environment = getenv("SKIKO_RENDER_API")
val property = getProperty("skiko.renderApi")
return parseRenderApi(environment ?: property)
}
Expand Down

0 comments on commit 29ae1d2

Please sign in to comment.