summaryrefslogtreecommitdiff
path: root/src/AppDirs.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2024-11-13 13:36:16 +0100
committerJörg Frings-Fürst <debian@jff.email>2024-11-13 13:36:16 +0100
commit34852b296a372a81d0b97ab4c12f32be6d294cd3 (patch)
tree4f751a1551d21c24e7fe66d2a7ddf4444d10a569 /src/AppDirs.vala
parent80aa3fe15f6346102c29b9c4236fe1e89c283d3b (diff)
parent4098950bba8e6d8609395eb9b223c276cb5954b6 (diff)
Merge branch 'release/debian/0.32.10-1'HEADdebian/0.32.10-1master
Diffstat (limited to 'src/AppDirs.vala')
-rw-r--r--src/AppDirs.vala31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/AppDirs.vala b/src/AppDirs.vala
index 05e172c..fd357c2 100644
--- a/src/AppDirs.vala
+++ b/src/AppDirs.vala
@@ -193,12 +193,39 @@ class AppDirs {
public static File get_exec_dir() {
return exec_dir;
}
+
+ public enum Runtime {
+ NATIVE,
+ FLATPAK,
+ SNAP,
+ UNKNOWN
+ }
+
+ private static Runtime _runtime = Runtime.UNKNOWN;
+
+ public static Runtime get_runtime() {
+ if (_runtime == Runtime.UNKNOWN) {
+ var snap = Environment.get_variable("SNAP_NAME");
+ if (snap != null) {
+ _runtime = Runtime.SNAP;
+ }
+ else {
+ var flatpak_canary = File.new_for_path("/.flatpak-info");
+ if (flatpak_canary.query_exists()) {
+ _runtime = Runtime.FLATPAK;
+ } else {
+ _runtime = Runtime.NATIVE;
+ }
+ }
+ }
+
+ return _runtime;
+ }
public static File get_temp_dir() {
if (tmp_dir == null) {
var basedir = Environment.get_tmp_dir();
- var flatpak_canary = File.new_for_path("/.flatpak-info");
- if (flatpak_canary.query_exists() && basedir == "/tmp") {
+ if (get_runtime() == Runtime.FLATPAK && basedir == "/tmp") {
basedir = Environment.get_user_cache_dir() + "/tmp";
}