Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

358.17. kdos-runner-0.1.0

KDOS in KRunner: kdos verbs, favourites, routes, packs on the boot medium, shortcuts, the offline library and the local model

Version 0.1.0, release 1
Source tree src/desktop/kdos-runner/
Phase 50_desktop (Desktop), 72 of 92 in build order
Licence MIT
Homepage https://github.com/kunaldawn/kdos
Build time 0.1 SBU
Installed size 177.7 KiB in 4 files
Recipe src/desktop/kdos-runner/kpkgbuild

About

kdos-runner puts KDOS into KRunner, the search that Alt+Space, Meta+Space and Kickoff’s search field open. It is KDOS’s own C, linked to basu and SQLite and to nothing from Qt, and it speaks KRunner’s D-Bus runner interface, org.kde.krunner1, under the bus name io.kdos.Runner with two objects. Two files under /usr/share/krunner/dbusplugins/ declare them to KRunner as two runners, and io.kdos.Runner.service lets the session bus start the program on the first query. It exits after ten minutes without a call.

One program serves both, so the library has no port of its own.

Ranking. /usr/share/kdos/xdg/krunnerrc names kdos first among KRunner’s favourite runners, whose categories KRunner sorts above every other whatever a row’s relevance. Without it Applications and System Settings lead, and night light + Enter starts an application. Because the ranking is per runner, two queries are held back on purpose:

KRunner keeps no order among rows of one relevance and shows only a runner’s first eight, so a verb’s values are ranked a step apart in their own order. accent lists next and prev first, or they would be its ninth and tenth rows and never on screen, then the accents in the order the boot menu shows them; desk names the desks as the desk picker does (KDOS, Dock, Tiling).

System Settings pages. KDOS’s settings pages are left to System Settings’ own runner, which finds them by their names and the X-KDE-Keywords of their metadata. The exception is a page’s whole title (the Name of its kcm_kdos_*.desktop): krunnerrc ranks Applications above System Settings, and the Applications runner allows one wrong letter in each word, so KDOS Look + Enter would open The KDOS Book. The palette therefore answers the whole title with the page, as Open KDOS Look over System Settings, because System Settings lists the page under its bare name too, and the library ranks its own rows for that title at most 0.42, by the same test of a title that the palette uses.

Titles in the library. For any query, KDOS Lo as much as KDOS Look, a library row whose title is a settings page’s name is retitled <name> in <source>, the source being its subtitle up to the · (KDOS Look in KDOS book for a chapter titled KDOS Look), because System Settings’ runner lists the page under its bare name for part of the title too. Any other title that two library rows of one answer share is retitled the same way (The firewall in Administration, The firewall in The security model): KRunner shows a subtitle on the selected row alone, and this keeps two rows from different sources from looking identical. Two headings of one name in one chapter both read <heading> in <chapter>.

lib <words> is a querySingleRunner call naming kdos-library, KRunner’s own single-runner mode. A ? prefix would not do: it cannot exclude other runners, and KRunner reads it as its help trigger.

Why it is in KDOS

The comment above it in script/phases/50_desktop/packages.txt:

The kdos verbs, routes and the offline library in KRunner, over D-Bus.

Sources

None: the port builds from its own directory, /kdos/src/desktop/kdos-runner.

Dependencies

Depends on: basu, sqlite, krunner.

Required by (1): kde-plasma.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/50_desktop/phase.env && kpkg install kdos-runner'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /kdos/src/desktop/kdos-runner.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/kdos-runner
SRC=$SRC_ROOT/kdos-runner-0.1.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

LIBS="$PORT_SRC/../../libs"

gcc $CFLAGS -O2 -std=gnu11 -D_GNU_SOURCE -Wall -Wextra \
	-I"$LIBS/libkbase" -I"$LIBS/libkxdg" -I"$LIBS/libkcolor" \
	$(pkg-config --cflags basu sqlite3) \
	-o kdos-runner "$PORT_SRC"/*.c \
	"$LIBS"/libkbase/*.c "$LIBS"/libkxdg/*.c "$LIBS"/libkcolor/*.c \
	$(pkg-config --libs basu sqlite3) $LDFLAGS

install -Dm755 kdos-runner "$PKG/usr/libexec/kdos/kdos-runner"
install -Dm644 "$PORT_SRC/io.kdos.Runner.service" \
	"$PKG/usr/share/dbus-1/services/io.kdos.Runner.service"
for _p in kdos kdos-library; do
	install -Dm644 "$PORT_SRC/$_p.desktop" \
		"$PKG/usr/share/krunner/dbusplugins/$_p.desktop"
done

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/kdos-runner, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf kdos-runner-0.1.0-1.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/kdos-runner, and runs the triggers its paths call for.

Other files in the port directory, read by build.sh: ask.c, http.c, io.kdos.Runner.service, json.c, kdos-library.desktop, kdos.desktop, library.c, main.c, match.c, query.c, run.c, runner.h, sources.c, tests/, zeal.c.

Notes

Every row is an argument vector built word by word and executed without a shell. A box name, a path after why, a search for Discover and the words of a route each reach the program as one argument; the tests run routes whose values are ;, $() and backquotes against stub programs and check that each arrives as written. A verb that prints its answer (update check, doctor, why) opens in Konsole with --hold; with two or more words after -e Konsole execs them as they are. box enter runs kdos-box enter <box> --window: kdos-box opens its own Konsole window, in the box’s accent profile, by itself only from a terminal, and started from the runner its shell would otherwise have none. A kdos verb run in the background is watched by a detached process, which posts the verb’s error output as a notification when it fails, so a refused kdos theme is never silent. The programs a row may start are kdos, kdos-box, kstart, systemsettings, plasma-discover, konsole, man, zeal and xdg-open; none is a dependency, and a missing one fails only its row.

KRunner sends Match on every keystroke and the palette answers from memory: each file it reads is parsed again only when its identity (device, inode, size, modification time) changes, and the tests hold every palette match under 50 ms. The library’s two servers are asked over loopback without blocking, and that Match is answered when both have answered or 250 ms have passed, whichever is first, so a slow server delays the library’s rows and never the palette’s. The book index is built once per install of kdos-doc or kdos-kfs, which the identity of their entries in the package database records, and is kept in ~/.cache/kdos/runner-books, whose first line names its line format, so a cache in another format is rebuilt rather than read. The runner builds it in a child process, since the two books are thousands of pages and the palette answers from the same loop; until the file is written the library answers without the books.

A match id stays good for ten seconds after KRunner’s Teardown. On Wayland KRunner sends Run only once the compositor has given it an activation token, and the Teardown it sends without waiting can arrive first; a runner that forgot its rows at Teardown would drop the click.

kiwix-serve routes a book by its file name without .zim, with _ for a space and plus for +; the runner reads the books from /var/lib/kiwix/library.xml, the file the local servers are started with. A Zeal docset is searched by name prefix in its own docSet.dsidx, in either of the two table layouts Zeal reads, and opened in Zeal as <family>:<name>. Place names are not searched: neither Organic Maps nor Marble has an offline index another program can query.

ask reaches the model through the same loopback client as the library, in two exchanges: /v1/models for the model to name, since llama-server runs as a router over every model under /usr/share/llama.cpp/models and refuses a request that names none, then /v1/chat/completions with the question, not streamed. It is sent 600 ms after the last keystroke (KDOS_RUNNER_ASK_QUIET_MS), because KRunner sends Match on every keystroke and each prefix of a question would otherwise be a request; a newer question closes the older one’s socket. The exchange has 30 seconds (KDOS_RUNNER_ASK_TIMEOUT_MS), but KRunner gives up on a Match reply after its D-Bus default of 25, so the Match is answered by 20 (KDOS_RUNNER_ASK_REPLY_MS) with a “still answering” row and the answer is kept ten minutes for the same question asked again. That row’s Run calls KRunner’s querySingleRunner with the question, and the answer’s Run calls Klipper’s setClipboardContents: two rows that run no program, each a D-Bus call from a detached child, so the loop never waits on Plasma. KDOS_RUNNER_LLAMA_PORT changes the port for the tests, whose fakeserve.py plays the router.

The runner ids kdos and kdos-library are an interface: kdos menu, the lib row and the tests query a single runner by id, and krunnerrc ranks kdos by it. Changing either breaks every caller that names it.