Skip to content

Commit

Permalink
Linux XDG folder support (SKCraft#518)
Browse files Browse the repository at this point in the history
  • Loading branch information
hedgehog1029 authored Jan 2, 2024
2 parents 93f6048 + 5712eb1 commit 847106f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,21 @@ private File getUserLauncherDir() {
String osName = System.getProperty("os.name").toLowerCase();
if (osName.contains("win")) {
return new File(getFileChooseDefaultDir(), getProperties().getProperty("homeFolderWindows"));
} else {
return new File(System.getProperty("user.home"), getProperties().getProperty("homeFolder"));
}

File dotFolder = new File(System.getProperty("user.home"), getProperties().getProperty("homeFolder"));
String xdgFolderName = getProperties().getProperty("homeFolderLinux");

if (osName.contains("linux") && !dotFolder.exists() && !xdgFolderName.isEmpty()) {
String xdgDataHome = System.getenv("XDG_DATA_HOME");
if (xdgDataHome.isEmpty()) {
xdgDataHome = System.getProperty("user.home") + "/.local/share";
}

return new File(xdgDataHome, xdgFolderName);
}

return dotFolder;
}

private static boolean isPortableMode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#

homeFolderWindows=Example Launcher
homeFolderLinux=example_launcher
homeFolder=.examplelauncher
launcherClass=com.skcraft.launcher.Launcher
latestUrl=http://update.skcraft.com/quark/launcher/latest.json
latestUrl=http://update.skcraft.com/quark/launcher/latest.json

0 comments on commit 847106f

Please sign in to comment.