Skip to content

Commit

Permalink
Merge pull request #63 from endlessm/default-kolibri-home
Browse files Browse the repository at this point in the history
Default KOLIBRI_HOME to $XDG_HOME/kolibri
  • Loading branch information
dylanmccall authored Sep 15, 2023
2 parents 72a637f + 7ef07b4 commit 7d5d0de
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
1 change: 0 additions & 1 deletion build-aux/flatpak/org.endlessos.Key.Devel.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"--socket=pulseaudio",
"--socket=wayland",
"--system-talk-name=org.endlessos.Key.Devel.Daemon",
"--env=KOLIBRI_HOME=~/.var/app/org.endlessos.Key.Devel/data/kolibri",
"--env=KOLIBRI_HTTP_PORT=0",
"--env=PYTHONPATH=/app/kolibri-plugins/lib/python",
"--env=KOLIBRI_APPS_BUNDLE_PATH=/app/share/endless-key/apps-bundle",
Expand Down
15 changes: 12 additions & 3 deletions src/kolibri_app/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,23 @@

XDG_CURRENT_DESKTOP = os.environ.get("XDG_CURRENT_DESKTOP")

# Logic for KOLIBRI_HOME is from kolibri.utils.conf. We avoid importing it from
# Kolibri because the import comes with side-effects.
DEFAULT_KOLIBRI_HOME_PATH = Path.home().joinpath(".kolibri")
# Logic for KOLIBRI_HOME that mimics kolibri.utils.conf except that
# $XDG_DATA_HOME/kolibri is used rather than ~/.kolibri so that the home
# directory doesn't need to be exposed in the flatpak.
if "XDG_DATA_HOME" in os.environ:
XDG_DATA_HOME = Path(os.environ["XDG_DATA_HOME"]).expanduser().absolute()
else:
XDG_DATA_HOME = Path.home().joinpath(".local/share")
DEFAULT_KOLIBRI_HOME_PATH = XDG_DATA_HOME.joinpath("kolibri")
if "KOLIBRI_HOME" in os.environ:
KOLIBRI_HOME_PATH = Path(os.environ["KOLIBRI_HOME"]).expanduser().absolute()
else:
KOLIBRI_HOME_PATH = DEFAULT_KOLIBRI_HOME_PATH

# Set KOLIBRI_HOME now so that kolibri's initialization doesn't set
# it back to ~/.kolibri.
os.environ["KOLIBRI_HOME"] = KOLIBRI_HOME_PATH.as_posix()


def init_gettext():
gettext.bindtextdomain(config.GETTEXT_PACKAGE, config.LOCALE_DIR)
Expand Down
2 changes: 1 addition & 1 deletion src/libkolibri_daemon_dbus/kolibri-daemon-dbus-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ kolibri_home_dir(void)
g_autofree gchar *kolibri_home = expanduser(g_getenv("KOLIBRI_HOME"));

if (kolibri_home == NULL || kolibri_home[0] == '\0')
return g_build_path("/", g_get_home_dir(), ".kolibri", NULL);
return g_build_path("/", g_get_user_data_dir(), "kolibri", NULL);

return g_steal_pointer(&kolibri_home);
}
Expand Down

0 comments on commit 7d5d0de

Please sign in to comment.