368. The application launchers
This page explains how the image makes sure its Start menu offers only applications it can actually run. Read it if you add application packs to a medium, or if a launcher appears for an application the machine does not have.
A boxed application, one that runs inside its own container (a box), reaches the desktop through four generated files:
- a desktop entry for the Start menu;
- a MIME cache for Open With;
- a table that maps each command name to its box;
- a shim in
/usr/local/bin, so the application can be started as a command.
kdos-appbox genlaunchers writes all four from the applications in a set of packs. script/phases/70_image/030_launchers.sh runs it against the packs the image carries, so the launchers on the medium match its packs exactly. The standard medium carries no application packs, so on a standard build this step removes every generated launcher.
The step
# The extraction root a bake would fill, created empty when absent. The
# reconcile has to run on a tree with no packs — that is the case that leaves
# ghosts — and genlaunchers reads a missing or empty directory alike, as no
# packs, and sweeps.
EXTRACT="${KDOS_PACK_EXTRACT:-/var/tmp/kdos-pack-extract}"
if ! command -v kdos-appbox >/dev/null 2>&1; then
echo "[launchers] kdos-appbox is not installed — skipping" >&2
exit 0
fi
mkdir -p "$EXTRACT"
echo "[launchers] reconciling alien launchers against $EXTRACT"
kdos-appbox genlaunchers --packs-dir "$EXTRACT" /
script/phases/70_image/030_launchers.sh, lines 49–62
--packs-dir reads one extracted pack per subdirectory, named after the pack, and takes each pack’s usr/share/applications. The other form, --packs, asks kdos-packd for the installed packs and mounts them, and there is no daemon and no mount in a build chroot. The last argument, /, is the root to write into, which in the chroot is the image stage, or build/fs under KDOS_IMAGE=full.
The extraction directory is /var/tmp/kdos-pack-extract unless KDOS_PACK_EXTRACT names another. script/chroot/exec.sh does not pass that variable into the chroot, so under make build it is always the default. Once kdos-appbox is found, the step creates the directory empty when it is missing and removes it again at the end if it is still empty; genlaunchers reads a missing directory as no packs and still sweeps. No step of the phase extracts a pack into it, so on a standard build it is empty.
genlaunchers reconciles rather than appends:
- It removes every desktop entry carrying
X-KDOS-Alien=true. - It removes every
/usr/local/binlink it recognises as its own shim: a symbolic link with a relative target or the target/usr/local/bin/kdos-appbox, except under a name it reserves, such askdos-boxandxdg-open. - It rewrites the table and the MIME cache whole, from the packs it found.
Against an empty source that is the clean-out; against one holding packs it is the population.
Run against the image, it also writes the skeleton’s KWin window rules, /etc/skel/.config/kwinrulesrc: one rule per pack box the image ships, in the neutral box colour scheme, because no box has a profile yet. Run by a user, the same command writes that user’s rules with each box’s accent and runs kbuildsycoca6, so the application menu and KRunner see the launchers at once. The four outputs and their naming rules are in Launcher generation.
kdos-appbox installs in /usr/local/bin, which is last on the chroot’s PATH. Without the kdos-appbox package the step prints that it is not installed and exits 0 before it creates anything, and whatever launchers the tree holds ship unchanged.
The check
TABLE=/usr/share/kdos/alien-apps
test -s "$TABLE"
rows=$(grep -vc '^#' "$TABLE" || true)
entries=$(find /etc/skel/.local/share/applications -name '*.desktop' \
-exec grep -l 'X-KDOS-Alien=true' {} + 2>/dev/null | wc -l)
echo "[launchers] $rows table row(s), $entries alien desktop entr(y|ies)"
# The two have to agree. A row with no entry is a shim nothing can launch from
# a menu; an entry with no row is the ghost this step exists to remove.
if [ "$rows" -eq 0 ] && [ "$entries" -ne 0 ]; then
echo "FATAL: $entries alien desktop entries survived a reconcile that" >&2
echo " found no packs. genlaunchers did not sweep them." >&2
exit 1
fi
rmdir "$EXTRACT" 2>/dev/null || true
script/phases/70_image/030_launchers.sh, lines 68–83
genlaunchers exits 0 whether it wrote anything or not, so the step checks what is on disk instead. The table, /usr/share/kdos/alien-apps, must exist and not be empty: with no packs it is its # header line alone. The step counts its rows and the alien desktop entries in /etc/skel/.local/share/applications, and prints both. A table with no rows beside alien entries means the sweep did not happen, and the phase stops.
Why it runs before 070_user.sh
The desktop entries are written into /etc/skel, the template for every home. 070_user.sh copies /etc/skel into /home/kdos, and the application menu reads the home’s entries before the system’s. Run after that step, the reconcile would clean /etc/skel and leave the old launchers in /home/kdos, offering applications whose packs the medium does not have.
The launchers are generated, not copied from fs/, so the fs/ manifest that removes files fs/ has dropped (see Files gone from fs/ are removed) never reaches them. This step is what removes them.
What it leaves
On the image:
| Path | Holds |
|---|---|
/etc/skel/.local/share/applications/ |
One desktop entry per boxed application, and its mimeinfo.cache |
/usr/share/kdos/alien-apps |
The command table, header line only when there are no packs |
/usr/local/bin/ |
One shim per boxed application |
On a standard build the first and last hold no generated launcher.
See also
- Launcher generation: every form of
genlaunchersand its outputs - Where a pack comes from: why the medium carries no applications
- Creating the homes: the step that copies
/etc/skel