358.7. kded-kdos-1.0.0
KDOS kded6 module — keeps the accent in step with Plasma, offers sets found on sticks, starts Samba for a login that can share folders, restarts a stopped plasmashell
| Version | 1.0.0, release 1 |
| Source tree | src/desktop/kded-kdos/ |
| Phase | 50_desktop (Desktop), 60 of 92 in build order |
| Licence | MIT |
| Homepage | https://github.com/kunaldawn/kdos |
| Build time | 0.1 SBU |
| Installed size | 196.6 KiB in 2 files |
| Recipe | src/desktop/kded-kdos/kpkgbuild |
About
kded-kdos is a kded6 module, kf6/kded/kdos.so, with four jobs a session has to do while nobody is looking at a KDOS window.
It keeps the accent in step with Plasma. An accent chosen inside Plasma — a KDOS global theme on the Global Theme page, a KDOS colour scheme on the Colours page, Quick Settings’ light and dark flip — changes the colour scheme and nothing below the desktop. The module watches kdeglobals [General] ColorScheme through a KConfigWatcher and, when it names a scheme KDOS ships (KDOS<Title> under /usr/share/color-schemes) that differs from the accent in ~/.config/kdos/accent, runs kdos theme --from-plasma <accent>; that carries the choice to the terminal programs, the Qt 5 palette, the wallpaper, the lock screen, the greeter, the boot menu and the console, and skips applying the global theme, so the run it starts cannot start another. A scheme that is not KDOS’s, or one that lives only in the user’s own color-schemes directory, changes nothing. See kdos theme.
It offers the application sets on a stick. When a removable volume is mounted, the top of it is listed once, off kded’s thread, for *.ktar files, the sets kdos app export writes; up to three are offered in one notification whose buttons open each in Discover (plasma-discover --local-filename <file>), where KDOS’s backend imports it offline and verifies every pack. Nothing is imported by the module itself.
It starts Samba for a login that can share folders. A folder shared from Dolphin’s Share tab is a file net usershare add writes into /var/lib/samba/usershares, and net turns every name in the share’s ACL, Dolphin’s Everyone among them, into a SID by asking the local smbd: with smbd down the share fails and nothing is written. samba’s service script starts smbd at boot once the sambashare group has a member, and an account the Share tab has just added to the group is a member from its next login, which can come before the next boot. So when a session of a member loads the module, it calls StartFileSharing on kdos-powerd’s io.kdos.Power1, which asks polkit (io.kdos.filesharing.start, granted to the person at the machine) and runs the service script’s start; with smbd already running that starts nothing. A failure raises one notification per reason in a session.
It starts plasmashell again when it stops. plasma_session starts plasmashell once and supervises nothing, and plasmashell exits normally when KWin crashes or is replaced; KCrash restarts it only after a crash signal. The module watches org.kde.plasmashell on the session bus and, once the name has been gone for three seconds and ksmserver’s isShuttingDown() answers false, starts plasmashell, at most five times in any minute; past that it raises one shellRespawnLimit notification. See How plasmashell is kept running.
Its state is on the session bus at org.kde.kded6 /modules/kdos, interface io.kdos.Kded1: accent(), syncState() (idle, running or failed), lastError() and resync(), with the signals accentSynced and accentSyncFailed, so a settings page or a script can ask what the last run did and start another. resync() runs kdos theme --from-plasma even when the accent file already names the scheme’s accent: the command writes that file before its other steps, so a run that failed half way leaves it in step, and a failure is failed until a run succeeds or the file is written again by a kdos theme run by hand.
Why it is in KDOS
The comment above it in script/phases/50_desktop/packages.txt:
The kded6 module that keeps the accent in step with Plasma and offers the sets it finds on a stick.
Sources
None: the port builds from its own directory, /kdos/src/desktop/kded-kdos.
Dependencies
Depends on: cmake, ninja, extra-cmake-modules, qt6-qtbase, kconfig, kcoreaddons, kdbusaddons, ki18n, knotifications, solid, kded, kdos-tools.
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 kded-kdos'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /kdos/src/desktop/kded-kdos.
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/kded-kdos
SRC=$SRC_ROOT/kded-kdos-1.0.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:
cmake -S "$PORT_SRC" -B build -G Ninja \
-D CMAKE_INSTALL_PREFIX=/usr \
-D KDE_INSTALL_LIBDIR=lib \
-D CMAKE_BUILD_TYPE=Release \
-D KDE_INSTALL_USE_QT_SYS_PATHS=ON \
-D BUILD_TESTING=OFF \
-Wno-dev
cmake --build build
DESTDIR=$PKG cmake --install build
The switches, and why each is set:
-S "$PORT_SRC"— The sources are the port’s own directory: a port of KDOS’s own has no tarball, and the build tree is made in the empty$SRC.-D KDE_INSTALL_USE_QT_SYS_PATHS=ON— Install the plugin into Qt’s own plugin directory,/usr/lib/qt6/plugins, where kded6 looks forkf6/kded.-D BUILD_TESTING=OFF— Build no tests into the package. The QtTest suite intests/is run bytesting/plasmatest.shin the development container, not by the image build.-D CMAKE_INSTALL_PREFIX=/usr,-D KDE_INSTALL_LIBDIR=lib,-D CMAKE_BUILD_TYPE=Release— The tree’s prefix and library directory, which ECM would otherwise put underlib64, and an optimised build.
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/kded-kdos, 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 kded-kdos-1.0.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/kded-kdos, and runs the triggers its paths call for.
Other files in the port directory, read by build.sh: CMakeLists.txt, src/, tests/.
Notes
The module id is the bare word kdos, not a dotted org.kdos.* plugin id: kded registers every module on the bus at /modules/<id>, and a dot is not allowed in an object path, so a dotted id would load and never be reachable.
A notified write is what wakes the watcher. Plasma’s colour and global-theme pages, and plasma-apply-colorscheme and plasma-apply-lookandfeel, all write kdeglobals with KConfig’s notify flag; a scheme set by editing the file by hand is noticed at the next login, when the module compares once on load.
kdos theme is looked for on the session’s PATH and then in /usr/local/bin, where kdos-tools installs it, because kded6 inherits whatever PATH the session started with. A run that has not finished after a minute is stopped. A run that fails, or a command that cannot be started, raises one notification per accent and reason in a session, with the last line the command printed. A boot menu and login screen left alone because kdos-powerd refused or did not answer is not a failure: kdos theme says so and exits 0, which is what keeps a user outside wheel, and the live medium, from a notification at every accent change.
Every file name in the stick offer comes off the stick, so it is escaped before it reaches the notification’s rich text and reaches Discover only as one element of an argument vector. Only a name ending in .ktar, in lower case, is offered: that is the spelling KDOS’s Discover backend and the installer open, and an offer Discover cannot open would be an empty page. A symlink, a hidden file, an empty file and anything below the top directory are never offered, and the listing stops after 4096 entries. A volume already mounted when the session starts is offered the next time it is mounted, not at every login.
Membership is what the session’s credentials can do: the usershare directory is root’s, group sambashare, mode 1770, so only a member can write into it. In any other session the module makes no call and logs once why, and that session cannot share a folder either. The call is made once per login and never again in it; a group joined during the session counts from the next login, as it does for net usershare itself.
The three seconds the module waits before it starts plasmashell cover plasmashell --replace and KCrash’s own restart, both of which leave the name free for a moment. A start inside that gap is still harmless, because plasmashell is a unique KDBusService and a second copy exits. A logout is told apart by asking ksmserver, which answers true while it is closing the session and is gone, or silent, once it has; either starts nothing. A plasmashell that exits before it takes its name drops nothing the watcher sees, so every start is followed by one look twenty seconds later.