371. Seeding the theme
This page explains why a new account on KDOS looks right from its first login, before anyone has opened a settings page. Read it if you change the default accent, or if a new home or the login screen comes up in the wrong colours.
An accent is one of KDOS’s named colour sets; every KDOS colour scheme, terminal palette and boot theme is generated from it. A new account starts with Plasma, Konsole, Qt 5 applications and the terminal programs all in the default accent.
Most of that is already on disk: the colour schemes, global themes, Konsole profiles and qt5ct palettes are installed under /usr/share by kdos-plasma-look and kdos-theme, and the global theme the first login applies comes from /etc/xdg/kdeglobals. What a home must carry itself is the accent’s name and the files of the programs that read only a home.
script/phases/70_image/050_theme.sh writes those into /etc/skel, from which 070_user.sh makes every home. In order, the step:
- checks that the accent it seeds is the one compiled into libkcolor;
- writes the theme into
/etc/skel, and checks what it wrote and the contrast of every installed colour scheme; - seeds the login screen’s look into the
sddmaccount’s home; - rebuilds two shared indexes that
fs/feeds.
The accent check
if ! diff -q <(kdos-bootctl theme --print) \
<(kdos-bootctl theme --print "$KDOS_ACCENT") >/dev/null; then
echo "FATAL: KDOS_ACCENT=$KDOS_ACCENT is not libkcolor's KCOL_DEFAULT_ID." >&2
echo " Change one of them; they name the same thing." >&2
exit 1
fi
script/phases/70_image/050_theme.sh, lines 31–36
kdos-bootctl theme --print prints the Limine theme block of an accent. With no name it uses libkcolor’s compiled default, KCOL_DEFAULT_ID; with a name, that accent. Identical output for the two means KDOS_ACCENT is the compiled default, and different output stops the phase.
The two must agree. A program of KDOS’s own that has no accent configured uses the compiled default; the files seeded here use KDOS_ACCENT. Were they different, the medium would seed one accent while every unconfigured program picked the other, and the desktop would change colour the first time anything was opened, which looks like a fault in that program.
Writing the theme into /etc/skel
HOME=/etc/skel XDG_CONFIG_HOME=/etc/skel/.config XDG_CACHE_HOME=/etc/skel/.cache \
XDG_DATA_HOME=/etc/skel/.local/share \
/usr/local/bin/kdos theme "$KDOS_ACCENT"
script/phases/70_image/050_theme.sh, lines 43–45
kdos theme <accent> is the command a user runs to switch accents (see Theming). Here it is run with HOME and the three XDG directories pointed into /etc/skel, so it writes into the template exactly what it would write into a home, outside a session: no Plasma call is made, and the global theme is left for the first login to apply. KConfig writes no key whose value /etc/xdg/kdeglobals already gives, so the home’s kdeglobals stays without LookAndFeelPackage here, and the accent the installer writes to that file reaches a new account. XDG_CONFIG_DIRS is unset, so the cascade holds no lock-screen picture, and kdos theme writes none: the template carries no kscreenlockerrc, and a new home takes its lock screen from the shipped /usr/share/kdos/xdg/kscreenlockerrc. The seeded files are therefore the same, byte for byte, as those of a kdos theme to the same accent.
The files it checks
test "$(cat /etc/skel/.config/kdos/accent)" = "$KDOS_ACCENT"
# Read through the cascade, as startplasma does at the first login, and not out
# of the file: KConfig writes no key whose value the machine's /etc/xdg/kdeglobals
# already gives, and that absence is what lets the installer's accent reach a
# new account.
_lnf=$(XDG_CONFIG_HOME=/etc/skel/.config kreadconfig6 --file kdeglobals --group KDE --key LookAndFeelPackage)
if [ "$_lnf" != "org.kdos.$KDOS_ACCENT.desktop" ]; then
echo "FATAL: a new home's global theme is '$_lnf', not org.kdos.$KDOS_ACCENT.desktop" >&2
exit 1
fi
# The Qt 5 applications have no Plasma platform theme, so qt5ct is their only
# way to the accent: its configuration must name a palette the image carries,
# or every Qt 5 application paints qt5ct's own defaults.
_qt5=$(sed -n 's/^color_scheme_path=//p' /etc/skel/.config/qt5ct/qt5ct.conf)
case "$_qt5" in
/usr/share/qt5ct/colors/KDOS-*.conf) test -s "$_qt5" ;;
*) echo "FATAL: skel's qt5ct.conf names no KDOS palette: '$_qt5'" >&2; exit 1 ;;
esac
# Every installed KDE colour scheme clears the contrast floors. The schemes
# are generated at build time from libkcolor's table; a palette edit that
# drops one role under 4.5:1 stops the image here rather than on a screen.
compgen -G '/usr/share/color-schemes/KDOS*.colors' >/dev/null
kdos-theme contrast -q /usr/share/color-schemes/KDOS*.colors
script/phases/70_image/050_theme.sh, lines 46–68
A value that is not the one asked for stops the phase, through set -e or an explicit FATAL. In order:
| Check | What it protects |
|---|---|
.config/kdos/accent names the accent |
The KDOS accent the terminal programs and kdos theme read |
kreadconfig6, through the cascade a login reads, answers org.kdos.<accent>.desktop |
The global theme Plasma applies at the first login, and with it the colour scheme, icons, fonts and wallpaper |
.config/qt5ct/qt5ct.conf names a KDOS palette the image carries |
Qt 5 applications, which have no Plasma platform theme and reach the accent only through qt5ct |
kdos-theme contrast over every KDOS*.colors |
Every installed colour scheme clears the contrast floors; a palette edit that drops a role under 4.5:1 stops the image here |
The login screen’s look
# THE LOGIN SCREEN WEARS THE ACCENT FROM THE FIRST BOOT. The greeter reads
# its look from the sddm account's home: ~/.config/kdeglobals, plasmarc and
# kcminputrc, and ~/kdos-background.png, the picture the KDOS greeter theme
# shows. kdos-powerd and the installer lay that set down when the accent is
# chosen; nothing chooses one on the live medium, so the image carries the
# default accent's set. All or nothing, as kdos-powerd's copy is: a missing
# file stops the image rather than shipping a greeter half in one accent. The
# home is handed to the account, which owns ~/.config because the greeter's
# KWin writes kwinoutputconfig.json there; a recursive chown is safe in the
# build root, where no account has run to leave a link.
echo "Seeding the $KDOS_ACCENT login screen into the sddm account's home..."
_gset=/usr/share/kdos/greeter/$KDOS_ACCENT
_ghome=$(awk -F: '$1 == "sddm" { print $6; exit }' /etc/passwd)
case "$_ghome" in
/var/lib/?*) ;;
*) echo "FATAL: the sddm account's home is '$_ghome', not under /var/lib" >&2; exit 1 ;;
esac
for _f in kdeglobals plasmarc kcminputrc background.png; do
test -s "$_gset/$_f" || { echo "FATAL: the $KDOS_ACCENT greeter set has no $_f" >&2; exit 1; }
done
install -d -m 0750 "$_ghome"
install -d -m 0755 "$_ghome/.config"
for _f in kdeglobals plasmarc kcminputrc; do
install -m 0644 "$_gset/$_f" "$_ghome/.config/$_f"
done
install -m 0644 "$_gset/background.png" "$_ghome/kdos-background.png"
chown -R sddm:sddm "$_ghome"
script/phases/70_image/050_theme.sh, lines 70–96
The SDDM greeter (the login screen) runs as the sddm account, and the KDOS greeter theme takes its look from that account’s home:
- the colour scheme, Plasma style and cursor from
~/.config/kdeglobals,plasmarcandkcminputrc; - its background from
~/kdos-background.png.
kdos-plasma-look builds one such set per accent into /usr/share/kdos/greeter/<accent>/. On an installed machine, the installer copies the installed accent’s set, and kdos theme later replaces it through kdos-powerd. On the live medium nothing chooses an accent, so this step copies the default accent’s set into /var/lib/sddm. A set missing a file stops the phase, just as kdos-powerd refuses a half set.
The home and everything in it are handed to the sddm account, because the greeter’s KWin writes its output configuration into ~/.config.
Finally the step writes the default accent’s name to /etc/kdos/accent. That file is the machine’s record of the accent the splash and the login screen wear; kdos-powerd and the installer rewrite it later, and the Look and About pages read it to say what the screens before login wear.
The two shared indexes
# The GSettings defaults (fs/usr/share/glib-2.0/schemas/90_kdos.gschema.override)
# reach GTK only through gschemas.compiled. kpkg's schemas trigger writes it
# when a package touches the directory, which an fs/-only rebuild never does,
# so it is rebuilt here from whatever the directory holds now. No glib means
# no GSettings reader, and no schema means nothing for the override to set:
# glib-compile-schemas then writes no index at all, and the check below would
# stop the image build.
if command -v glib-compile-schemas >/dev/null 2>&1 &&
compgen -G '/usr/share/glib-2.0/schemas/*.gschema.xml' >/dev/null; then
glib-compile-schemas /usr/share/glib-2.0/schemas
test -s /usr/share/glib-2.0/schemas/gschemas.compiled
fi
# The desktop entries fs/ ships (the kdos-* handlers) reach `kdos-appbox open`
# and Plasma's Open With only through
# /usr/share/applications/mimeinfo.cache. kpkg's desktop trigger
# writes it when a package touches the directory, which an fs/-only rebuild
# never does, so it is rebuilt here too.
if command -v update-desktop-database >/dev/null 2>&1 &&
[ -d /usr/share/applications ]; then
update-desktop-database -q /usr/share/applications
fi
script/phases/70_image/050_theme.sh, lines 106–127
fs/ ships two kinds of file that reach their readers only through an index. KDOS’s GSettings defaults, fs/usr/share/glib-2.0/schemas/90_kdos.gschema.override, take effect only once glib-compile-schemas has written gschemas.compiled. The desktop entries fs/ ships, the kdos-* handlers, reach kdos-appbox open and Plasma’s Open With only through /usr/share/applications/mimeinfo.cache, which update-desktop-database writes.
kpkg rebuilds both whenever a package installs into those directories. A build that changes only fs/ installs no package, so kpkg never does, and the step rebuilds both itself from what the directories hold. Each is skipped when its tool is not installed, the desktop index also when /usr/share/applications does not exist, and the schema index also when there is no schema to compile: glib-compile-schemas then writes no index at all, and the test -s after it would stop the phase.
What it leaves
On the image, the seeded files under /etc/skel, which 070_user.sh copies into /home/kdos and which useradd -m copies into an account made later; the greeter’s set in /var/lib/sddm, owned by sddm; and /usr/share/glib-2.0/schemas/gschemas.compiled and /usr/share/applications/mimeinfo.cache, rewritten.
See also
- Theming: the accents, switching them, and what reads which file
- kdos theme: the command
- Shared indexes: the indexes kpkg rebuilds on install