From 72c23b0417f41e7372dcd0fe5b04aa476e8fd83f Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Sun, 13 Jun 2021 16:48:17 +0100 Subject: [PATCH] Try to follow XDG Base dir standard if not on Windows or Mac, GitHub issue #7 --- gui/griffon-app/lifecycle/Initialize.groovy | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/gui/griffon-app/lifecycle/Initialize.groovy b/gui/griffon-app/lifecycle/Initialize.groovy index a039fb40..60a8702e 100644 --- a/gui/griffon-app/lifecycle/Initialize.groovy +++ b/gui/griffon-app/lifecycle/Initialize.groovy @@ -178,6 +178,12 @@ class Initialize extends AbstractLifecycleHandler { } } + /** + * Selects home directory for MuWire using the following rules: + * 1. if $HOME/.MuWire already exists, use that + * 2. Otherwise if on Windows or Mac use OS-specific convention + * 3. Otherwise try to follow the XDG Base dir standard + */ private static String selectHome() { def home = new File(System.properties["user.home"]) def defaultHome = new File(home, ".MuWire") @@ -195,7 +201,15 @@ class Initialize extends AbstractLifecycleHandler { def muwire = new File(roaming, "MuWire") return muwire.getAbsolutePath() } - defaultHome.getAbsolutePath() + // see if XDG standard can be followed + String xdgConfigVar = System.getenv("XDG_CONFIG_HOME") + File xdgConfigHome + if (xdgConfigVar == null || xdgConfigVar.length() == 0) + xdgConfigHome = new File(home, ".config") + else + xdgConfigHome = new File(xdgConfigVar) + File xdgMWHome = new File(xdgConfigHome, "MuWire") + xdgMWHome.getAbsolutePath() } private String showLanguageDialog() {