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

226.1. kdos-tools-1.3.0

KDOS system tools — kdos, services, getty, slots, fetch

Version 1.3.0, release 1
Source tree src/system/kdos-tools/
Phase 42_graphics (Graphics Stack), 165 of 189 in build order
Licence MIT AND (BSD-2-Clause OR CC0-1.0)
Homepage https://github.com/kunaldawn/kdos
Build time 0.6 SBU
Installed size 1.3 MiB in 75 files
Recipe src/system/kdos-tools/kpkgbuild

About

kdos-tools is one binary with many names, and most of the KDOS commands a person types are this port. Installed once as /usr/sbin/ksvc, it is

main.c picks the tool from the name it was started under, and every other name is a symbolic link build.sh makes; run as kdos-tools, the first argument names the tool. The names, where each is installed and where each is documented are in ksvc — 12 names and The kdos command. /usr/sbin/service and /usr/local/sbin/kdos-getty come from this package, not from fs/.

The package also carries data and desktop entries the commands use:

File What it is for
/usr/share/kdos/reasons/ The reasons corpus that kdos why and kdos explain browse
/usr/share/kdos/secdb.txt The vulnerability database kdos cve matches installed packages against
/usr/share/kdos/bundled.txt The list of libraries ports compile in from vendored crates, for kdos cve
/usr/share/applications/kdos-help.desktop The KDOS Help menu entry, which runs kdos help --pager in a terminal
/usr/share/kglobalaccel/org.kdos.tiling.desktop Binds Meta+Shift+T to kdos tiling toggle
/usr/share/kglobalaccel/org.kdos.nightlight.desktop Binds Meta+Ctrl+Shift+N to kdos toggle night-light
/etc/xdg/autostart/kdos-mpris.desktop Starts kdos-mpctl mpris at a Plasma login where mpd is installed, so Plasma’s media keys, Media Player applet and lock screen reach mpd over MPRIS
/etc/xdg/autostart/kdos-speech-sync.desktop Runs kdos speech sync at a Plasma login, which offers Klipper’s Read Aloud action while a voice is installed and takes it away when none is
/usr/share/kio/servicemenus/kdos-share.desktop Dolphin’s Send with a Code Word action, which runs kdos-share on the selection
/usr/share/kio/servicemenus/kdos-verify.desktop The Verify action on every file, which runs kdos verify --notify on the selection
/usr/share/knotifications6/kdos.notifyrc The notification events the commands post

kdos verify links nothing new: its SHA-512 is Monocypher’s, already linked through libksig for signatures.

The depends line is mostly programs it runs rather than libraries it links:

kdos-pack is there for the kdos app verbs, which reach it through kdos-appbox when they build, export or import a box.

basu is the session and system bus every Plasma-facing verb talks over; it is opened at run time and not linked (see Notes). kbd depends on libxkbcommon, a 42_graphics port, so this port is built in that phase and not with the other src/system programs in 41_system. The Plasma programs some verbs run — kwriteconfig6, plasma-apply-lookandfeel, spectacle, kdialog, kscreen-doctor — are built in later phases and are not in depends: each verb that needs one finds it on PATH when it runs and says so when it is missing.

Why it is in KDOS

The comment above it in script/phases/42_graphics/packages.d/src-system.txt:

Service supervisor and the console getty wrapper (src/system, ours). /usr/sbin/service and /usr/local/sbin/kdos-getty come from this port, not from fs/.

Sources

None: the port builds from its own directory, /kdos/src/system/kdos-tools.

Dependencies

Depends on: kbd, procps-ng, alsa-utils, basu, kdos-pack, croc, qrencode, curl, zstd, wl-clipboard.

Required by (11): kcm-kdos-health, kcm-kdos-look, kded-kdos, kdos-discover, kdos-notice, kdos-sounds, kdos-sysupdated, kdos-transcribe, kdos-welcome, plasmoid-kdos-checklist, plasmoid-kdos-privacy.

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/42_graphics/phase.env && kpkg install kdos-tools'

What kpkg does

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

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-tools
SRC=$SRC_ROOT/kdos-tools-1.3.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/libkcolor" -I"$LIBS/libkpkg" \
	-I"$LIBS/libkxdg" -I"$LIBS/libkproc" -I"$LIBS/libksig" \
	-I"$LIBS/libkpack" -I"$LIBS/libkbuild" -I"$PORT_SRC" \
	-o kdos-tools \
	"$PORT_SRC"/*.c \
	"$LIBS"/libkbase/*.c "$LIBS"/libkcolor/*.c "$LIBS"/libkpkg/*.c \
	"$LIBS"/libkxdg/*.c "$LIBS"/libkproc/*.c \
	"$LIBS"/libksig/*.c "$LIBS"/libksig/monocypher/*.c \
	"$LIBS"/libkpack/*.c "$LIBS"/libkbuild/kb_json.c $LDFLAGS

install -Dm755 kdos-tools "$PKG/usr/sbin/ksvc"
install -Dm644 "$PORT_SRC/kglobalaccel/org.kdos.tiling.desktop" \
	"$PKG/usr/share/kglobalaccel/org.kdos.tiling.desktop"
install -Dm644 "$PORT_SRC/kglobalaccel/org.kdos.nightlight.desktop" \
	"$PKG/usr/share/kglobalaccel/org.kdos.nightlight.desktop"
install -Dm644 "$PORT_SRC/autostart/kdos-mpris.desktop" \
	"$PKG/etc/xdg/autostart/kdos-mpris.desktop"
install -Dm644 "$PORT_SRC/autostart/kdos-speech-sync.desktop" \
	"$PKG/etc/xdg/autostart/kdos-speech-sync.desktop"

ln -s ksvc "$PKG/usr/sbin/service"
install -d "$PKG/usr/local/sbin"
ln -s /usr/sbin/ksvc "$PKG/usr/local/sbin/kdos-getty"

install -d "$PKG/usr/local/bin"
for t in kdos kdos-banner kdos-shot kdos-share kdos-fetch-app \
	 kdos-fetch-static kdos-sfx kdos-mpctl; do
	ln -s /usr/sbin/ksvc "$PKG/usr/local/bin/$t"
done

install -d "$PKG/usr/bin"
ln -s /usr/sbin/ksvc "$PKG/usr/bin/kdos-bootctl"

install -Dm644 "$PORT_SRC/servicemenus/kdos-share.desktop" \
	"$PKG/usr/share/kio/servicemenus/kdos-share.desktop"
install -Dm644 "$PORT_SRC/servicemenus/kdos-verify.desktop" \
	"$PKG/usr/share/kio/servicemenus/kdos-verify.desktop"

install -d "$PKG/usr/share/kdos/reasons"
install -m644 "$PORT_SRC"/reasons/*.txt "$PKG/usr/share/kdos/reasons/"

install -Dm644 "$PORT_SRC/secdb/secdb.txt" "$PKG/usr/share/kdos/secdb.txt"
install -Dm644 "$PORT_SRC/secdb/bundled.txt" "$PKG/usr/share/kdos/bundled.txt"

install -d "$PKG/usr/share/applications"
cat > "$PKG/usr/share/applications/kdos-help.desktop" <<'EOF'
[Desktop Entry]
Type=Application
Name=KDOS Help
GenericName=Keybinds and commands
Comment=KDOS cheat sheet — commands and keybinds
Exec=kdos help --pager
Icon=help-contents
Terminal=true
Categories=System;Documentation;
Keywords=help;keys;keybinds;cheatsheet;kdos;
EOF
chmod 644 "$PKG/usr/share/applications/kdos-help.desktop"

install -Dm644 "$PORT_SRC/kdos.notifyrc" \
	"$PKG/usr/share/knotifications6/kdos.notifyrc"

install -Dm644 "$LIBS/libksig/monocypher/LICENCE.md" \
	"$PKG/usr/share/licenses/$name/monocypher-LICENCE.md"

The switches, and why each is set:

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-tools, 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-tools-1.3.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-tools, and runs the triggers its paths call for.

Other files in the port directory, read by build.sh: app.c, appid.c, autostart/, backup.c, banner.c, bootctl.c, bus.c, checklist.c, clip.c, clone.c, cve.c, desk.c, fetch.c, firmware.c, getty.c, hey.c, image.c, kcfg.c, kdos-tools.h, kdos.c, kdos.notifyrc, keys.c, kglobalaccel/, ksvc.c, machine.c, main.c, march.c, mpctl.c, oracle.c, persist.c, phosphor.c, places.c, privacy.c, reasons/, rebuild.c, relidx.c, remind.c, restarts.c, sandbox.c, secdb/, servicemenus/, sfx.c, share.c, shot.c, speech.c, theme.c, themeaudit.c, thumb.c, toggle.c, trash.c, update.c, verify.c, why.c, windows.c.

Contents

Installed programs: kdos, kdos-banner, kdos-bootctl, kdos-fetch-app, kdos-fetch-static, kdos-getty, kdos-mpctl, kdos-sfx, kdos-share, kdos-shot, ksvc, service.

Installed directories: /usr/local/sbin, /usr/share/kdos/reasons, /usr/share/licenses/kdos-tools.

Notes

The table in main.c and the links build.sh installs have to agree. A name in the table with no link is a tool nothing can start; a link with no name in the table makes the binary print the names it knows and exit with status 1.

The bus is libbasu, opened with dlopen when a verb first needs it (bus.c), and not linked. kdos-bootctl is in the initramfs, and the image step copies it through its link, so what lands there is this whole binary with its linked closure; a linked libbasu would be one more library the initramfs has to carry for a command that never uses a bus there. A development host has the same API as libsystemd, which bus.c opens when there is no libbasu, so the self-test drives the Plasma-facing verbs against a private bus on any host. See kdos-bootctl.

kdos hey and kdos appid read KWin’s window list over the Wayland wire protocol, spoken in windows.c itself — a registry, one bind and a request per window — rather than through a client generated from the protocol file: that file comes from plasma-wayland-protocols, a 43_toolkits port built a phase after this one, and the generated client would put libwayland-client under the binary the initramfs carries. The opcodes are those of plasma-window-management.xml at interface version 21, and no version above that is bound, so an event KWin adds later is never sent.

kdos image (image.c) both makes a release’s whole-slot image and writes one into the inactive slot, so the format has one reader and one writer. An image is

The difference is taken per file and not over the whole slot because --patch-from needs a window covering its reference and the window stops at 2 GiB, which one slot with Plasma and the Gear applications exceeds several times over. A bundle is never signed: every object is checked against the manifest’s hash before it is kept, so a tampered bundle costs a download and never a file.

A slot is written by synchronising it, not formatting it — what it or the running root already holds with the right hash is copied — so it keeps the filesystem and UUID the installer gave it, whichever of the four that is. The format refuses a file capability or an ACL rather than dropping it. Under /var/log, /var/cache and /var/tmp an image holds the directories and none of the files: packages own directories there (/var/log/cups), and a slot without them fails kpkg check and is never armed.

secdb/secdb.txt is generated by secdb/vendor.py from Alpine’s security database, on a development host with network, and committed; the build only installs it. secdb/corrections.txt names the rows Alpine recorded under a version upstream never released, each with the right version or drop; vendor.py applies it whenever it writes the table, and vendor.py --corrections applies it to the committed table offline. A match in the table is keyed to Alpine’s package names, so a port whose name differs from Alpine’s carries secdb = in its recipe. bundled.txt is kept by hand: a port whose version bump moves a vendored crate changes its row in the same change.