Skip to content

Commit

Permalink
Merge pull request #172 from endlessm/T35760-generate-endless-key-per…
Browse files Browse the repository at this point in the history
…-channel-launchers

Populate .desktop files for Endless Key channels
  • Loading branch information
wjt committed Jan 19, 2025
2 parents cc21f84 + 4e7bd81 commit 8b1be5b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions config/defaults.ini
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,12 @@ regular_users_can_manage_content = false
# pre-release not on PyPI.
kolibri_pkgspec = https://github.com/learningequality/kolibri/releases/download/v0.16.0-beta6/kolibri-0.16.0b6-py2.py3-none-any.whl

# Kolibri xdg desktop file plugin to use when preloading channels. Out of the
# box these desktop files are not used for Endless Key, but some OS images may
# add them to the search path, so we should ensure they are pregenerated in the
# OS image.
kolibri_app_desktop_xdg_plugin_version = 1.3.0

# Which Endless Key collections to preload in the image.
# Must match the name of one of the collections shipped with the Endless Key
# (ex. artist, explorer, spanish etc).
Expand Down
17 changes: 17 additions & 0 deletions hooks/image/53-ek-content-preload
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ venv_dir="${EIB_TMPDIR}/kolibri-content-venv"
python3 -m venv ${venv_dir}
source ${venv_dir}/bin/activate
pip install "${EIB_ENDLESSKEY_KOLIBRI_PKGSPEC}"
pip install kolibri-app-desktop-xdg-plugin==${EIB_ENDLESSKEY_KOLIBRI_APP_DESKTOP_XDG_PLUGIN_VERSION}

# Setup the homedir before setting any environment variables so they
# don't persist into the options file.
export KOLIBRI_HOME="${OSTREE_VAR}"/lib/endless-key/data
mkdir -p "${KOLIBRI_HOME}"
kolibri plugin enable kolibri_app_desktop_xdg_plugin
kolibri configure setup

# Use a separate content URL if configured.
Expand All @@ -50,6 +52,11 @@ if [ -n "${EIB_KOLIBRI_CENTRAL_CONTENT_BASE_URL}" ]; then
export KOLIBRI_CENTRAL_CONTENT_BASE_URL
fi

# kolibri-app-desktop-xdg-plugin uses FLATPAK_ID to determine how to name the
# launchers it creates. This is set by Flatpak when running the app, but we are
# not running kolibri from within the Endless Key Flatpak here.
export FLATPAK_ID=org.endlessos.Key

# Import all channel metadata and thumbnails for all channels
for channel in $all_channels; do
kolibri manage --skip-update importchannel network "${channel}"
Expand Down Expand Up @@ -84,6 +91,16 @@ fi
# <https://kolibri.readthedocs.io/en/latest/install/provision.html#prepare-the-kolibri-folder-for-copying>
(echo yes; echo yes) | kolibri manage --skip-update deprovision

# Hack the .desktop files to work around them being generated differently when
# the xdg plugin is running in the Flatpak, which it is not here.
for desktop_file in "${OSTREE_VAR}"/lib/endless-key/data/content/xdg/share/applications/*.desktop; do
sed -i -e 's/x-kolibri-dispatch:/x-endless-key-dispatch:/g' "${desktop_file}"
desktop-file-edit \
--set-key=TryExec \
--set-value=/var/lib/flatpak/app/org.endlessos.Key/current/active/files/bin/kolibri-gnome \
"${desktop_file}"
done

# Chown all the files to the kolibri user. This also happens at runtime
# via the endless-key.conf tmpfiles.d configuration.
kolibri_uid=$(ostree_uid kolibri)
Expand Down

0 comments on commit 8b1be5b

Please sign in to comment.