diff --git a/detectflatpak.patch b/detectflatpak.patch new file mode 100644 index 0000000..9bbf5de --- /dev/null +++ b/detectflatpak.patch @@ -0,0 +1,56 @@ +diff --git a/Source/Core/UICommon/UICommon.cpp b/Source/Core/UICommon/UICommon.cpp +index cb857fd3c7..47a012c4f0 100644 +--- a/Source/Core/UICommon/UICommon.cpp ++++ b/Source/Core/UICommon/UICommon.cpp +@@ -306,19 +306,45 @@ void SetUserDirectory(std::string custom_path) + user_path = home_path + DOLPHIN_DATA_DIR DIR_SEP; + } + #else +- // We are on a non-Apple and non-Android POSIX system, there are 4 cases: +- // 1. GetExeDirectory()/portable.txt exists ++ // We are on a non-Apple and non-Android POSIX system, there are 5 cases: ++ // 1. Running inside flatpak sandbox ++ // -> Use XDG basedir ++ // 2. GetExeDirectory()/portable.txt exists + // -> Use GetExeDirectory()/User +- // 2. $DOLPHIN_EMU_USERPATH is set ++ // 3. $DOLPHIN_EMU_USERPATH is set + // -> Use $DOLPHIN_EMU_USERPATH +- // 3. ~/.dolphin-emu directory exists ++ // 4. ~/.dolphin-emu directory exists + // -> Use ~/.dolphin-emu +- // 4. Default ++ // 5. Default + // -> Use XDG basedir, see + // http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html + user_path = home_path + "." DOLPHIN_DATA_DIR DIR_SEP; + std::string exe_path = File::GetExeDirectory(); +- if (File::Exists(exe_path + DIR_SEP "portable.txt")) ++ if (File::Exists(DIR_SEP ".flatpak-info")) ++ { ++ const char* data_home = getenv("XDG_DATA_HOME"); ++ std::string data_path = ++ std::string(data_home && data_home[0] == '/' ? data_home : ++ (home_path + ".local" DIR_SEP "share")) + ++ DIR_SEP DOLPHIN_DATA_DIR DIR_SEP; ++ ++ const char* config_home = getenv("XDG_CONFIG_HOME"); ++ std::string config_path = ++ std::string(config_home && config_home[0] == '/' ? config_home : ++ (home_path + ".config")) + ++ DIR_SEP DOLPHIN_DATA_DIR DIR_SEP; ++ ++ const char* cache_home = getenv("XDG_CACHE_HOME"); ++ std::string cache_path = ++ std::string(cache_home && cache_home[0] == '/' ? cache_home : (home_path + ".cache")) + ++ DIR_SEP DOLPHIN_DATA_DIR DIR_SEP; ++ ++ File::SetUserPath(D_USER_IDX, data_path); ++ File::SetUserPath(D_CONFIG_IDX, config_path); ++ File::SetUserPath(D_CACHE_IDX, cache_path); ++ return; ++ } ++ else if (File::Exists(exe_path + DIR_SEP "portable.txt")) + { + user_path = exe_path + DIR_SEP "User" DIR_SEP; + } diff --git a/forcexdg.patch b/forcexdg.patch deleted file mode 100644 index 51ac030..0000000 --- a/forcexdg.patch +++ /dev/null @@ -1,45 +0,0 @@ -diff --git a/Source/Core/UICommon/UICommon.cpp b/Source/Core/UICommon/UICommon.cpp -index 2055c4d863..163a15f8a5 100644 ---- a/Source/Core/UICommon/UICommon.cpp -+++ b/Source/Core/UICommon/UICommon.cpp -@@ -273,28 +273,11 @@ void SetUserDirectory(const std::string& custom_path) - user_path = home_path + DOLPHIN_DATA_DIR DIR_SEP; - } - #else -- // We are on a non-Apple and non-Android POSIX system, there are 4 cases: -- // 1. GetExeDirectory()/portable.txt exists -- // -> Use GetExeDirectory()/User -- // 2. $DOLPHIN_EMU_USERPATH is set -- // -> Use $DOLPHIN_EMU_USERPATH -- // 3. ~/.dolphin-emu directory exists -- // -> Use ~/.dolphin-emu - // 4. Default - // -> Use XDG basedir, see - // http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html - user_path = home_path + "." DOLPHIN_DATA_DIR DIR_SEP; - std::string exe_path = File::GetExeDirectory(); -- if (File::Exists(exe_path + DIR_SEP "portable.txt")) -- { -- user_path = exe_path + DIR_SEP "User" DIR_SEP; -- } -- else if (env_path) -- { -- user_path = env_path; -- } -- else if (!File::Exists(user_path)) -- { - const char* data_home = getenv("XDG_DATA_HOME"); - std::string data_path = - std::string(data_home && data_home[0] == '/' ? data_home : -@@ -316,11 +299,9 @@ void SetUserDirectory(const std::string& custom_path) - File::SetUserPath(D_CONFIG_IDX, config_path); - File::SetUserPath(D_CACHE_IDX, cache_path); - return; -- } - #endif - } - #endif -- File::SetUserPath(D_USER_IDX, std::move(user_path)); - } - - void SaveWiimoteSources() diff --git a/org.DolphinEmu.dolphin-emu.yml b/org.DolphinEmu.dolphin-emu.yml index 027b0b0..858f72f 100644 --- a/org.DolphinEmu.dolphin-emu.yml +++ b/org.DolphinEmu.dolphin-emu.yml @@ -112,11 +112,13 @@ modules: - type: git url: https://github.com/dolphin-emu/dolphin.git commit: 8ecfa537a242de74d2e372e30d9d79b14584b2fb + # detects whether dolphin is running in a flatpak sandbox + # and makes it use xdg directories if it is. # prevents dolphin from attempting to write conf files # in non-writable paths, typically happens when a user # has leftover files from a previous non-flatpak install - type: patch - path: forcexdg.patch + path: detectflatpak.patch # version strings must match exactly for online multiplayer - type: patch path: nodirtyversion.patch