Skip to content

Commit 7e7d916

Browse files
committed
Use XDG_CONFIG_HOME for config directory
1 parent d489ca4 commit 7e7d916

File tree

4 files changed

+24
-18
lines changed

4 files changed

+24
-18
lines changed

flatpak/ch.bailu.gtk_meteo.json

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77
"org.freedesktop.Sdk.Extension.openjdk17"
88
],
99
"command": "gtk-meteo.sh",
10+
"finish-args": [
11+
"--share=network",
12+
"--share=ipc",
13+
"--socket=wayland",
14+
"--socket=fallback-x11",
15+
"--device=dri",
16+
"--env=GIO_EXTRA_MODULES=/app/lib/gio/modules",
17+
"--env=JAVA_HOME=/app/jre",
18+
"--env=LIBO_FLATPAK=1",
19+
"--env=PATH=/app/bin:/app/jre/bin"
20+
],
1021
"modules": [
1122
{
1223
"name": "openjdk",
@@ -22,7 +33,7 @@
2233
{
2334
"type": "git",
2435
"url": "https://github.com/bailuk/gtk-meteo.git",
25-
"branch": "543eb0a5ff40b57d70277fb6c7ac9b3e6f9fb431"
36+
"commit": "543eb0a5ff40b57d70277fb6c7ac9b3e6f9fb431"
2637
},
2738
"gradle-sources.json"
2839
],
@@ -36,18 +47,5 @@
3647
"install -Dm644 src/main/resources/svg/app-icon.svg /app/share/icons/hicolor/scalable/apps/ch.bailu.gtk_meteo.svg"
3748
]
3849
}
39-
],
40-
"finish-args": [
41-
"--share=network",
42-
"--share=ipc",
43-
"--socket=wayland",
44-
"--socket=fallback-x11",
45-
"--device=dri",
46-
"--env=GIO_EXTRA_MODULES=/app/lib/gio/modules",
47-
"--env=JAVA_HOME=/app/jre",
48-
"--env=LIBO_FLATPAK=1",
49-
"--env=PATH=/app/bin:/app/jre/bin",
50-
"--filesystem=~/.config/gtk-meteo",
51-
"--filesystem=~/.java/.userPrefs/gtk-meteo"
5250
]
5351
}

flatpak/flatpak-pin-commit.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ git_hash=$(git show --format="%H" --no-patch)
55

66
echo "_"
77
echo "update '${out_file}' (commit: $git_hash)"
8-
sed -i 's/"branch": .*"/"branch": '\"${git_hash}\"'/g' "${out_file}"
8+
sed -i 's/"commit": .*"/"commit": '\"${git_hash}\"'/g' "${out_file}"

src/main/kotlin/config/Files.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ import config.Strings.userAgent
44
import java.io.File
55

66
object Files {
7-
val configDirectory =
8-
File(System.getProperty("user.home") + "/.config/$userAgent/")
7+
8+
private val configHome = (System.getenv("XDG_CONFIG_HOME")
9+
?: (System.getProperty("user.home") + "/.config")) + "/$userAgent"
10+
val configDirectory = File(configHome)
911

1012
init {
13+
println("CONFIG_HOME: $configHome")
1114
configDirectory.mkdirs()
1215
}
1316

src/main/kotlin/controller/Prefs.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
package controller
22

3+
import config.Files
34
import config.Keys
45
import java.util.prefs.Preferences
56

67
object Prefs {
7-
private val prefs = Preferences.userRoot().node("gtk-meteo")
8+
private val prefs: Preferences
89

10+
init {
11+
System.setProperty("java.util.prefs.userRoot", Files.configDirectory.path)
12+
prefs = Preferences.userRoot().node("gtk-meteo")
13+
}
914
fun putAutoCycle(value: Boolean) {
1015
prefs.putBoolean(Keys.AUTO_CYCLE, value)
1116
}

0 commit comments

Comments
 (0)