For new user accounts, Plasma/KDE ignores the environment variable LANG
, but falls back to C.UTF-8
. Moreover it creates a file ~/.config/plasma-localerc
with LANG=C.utf8
.
Users can open the system settings and change their locale which updates plasma-localerc
to the correct value, but it is annoying. Moreover the system settings greet the user with the warning that C.utf8
was not a valid locale.
Where does KDE take that value C.utf8
(or C.UTF-8
) from?
I already found a work-around. If I put .config/plasma-localerc
into /etc/skel
(or in any home directory for users which haven’t yet logged in) with the desired value, Plasma/KDE uses that value. But I am really more interested where Plasma/KDE initially takes the wrong value C.UTF-8
from, if plasma-localerc
doesn’t exist yet and Plasma/KDE generates it automatically.
Here is my setup which is a little bit more complex than usual, because I want all system daemons to run with C.UTF-8
(for untranslated log messages), but all user-facing daemons and all UI should be de_DE.UTF-8
.
- Localization for System
/etc/locale.conf
setsLANG=C.UTF-8
/etc/env.d/02locale
is a symbolic link to/etc/locale.conf
(I am a Genoo user.)/etc/profile.env
is a generated file (from/etc/locale.conf
and hence also setsLANG=C.UTF-8
./etc/environment.d/10-gentoo-env.conf
, see previous point
- Localization for User-Facing Services and User Default
/etc/locale-users.conf
setsLANG=de_DE.UTF-8 GDM_LANG=de_DE.UTF-8 LANGUAGE=de_DE:en_US
/etc/environment.d/20-locale.conf
is a symbolic link to/etc/locale-users.conf
; as it is lexicographically later, it overrides/etc/environment.d/10-gentoo-env.conf
The SystemD User Service Manager parses the directory/etc/environment.d/
for each user service it starts.- For the SystemD User Service Manager itself, I have a service drop-in via
/etc/systemd/system/user@.service.d/override.conf
with:
(The idea for that is from Arch Wiki: SystemD User - Environment Variables.)[Service] EnvironmentFile=-/etc/locale-users.conf
- Localization for Individual Users
- In
/etc/skel
and home directory of each user the file.config/environment.d/20-locale.conf
setsLANG=de_DE.UTF-8
- In
I can confirm that the setup generally works as it should. For any other environment variable than LANG
the command systemctl --user show-environment
outputs the value as set in locale-users.conf
. However, for LANG
Plasma/KDE somehow seems to overwrite it and fall back to C.UTF-8
. Why?
My only explanation so far is that Plasma/KDE explicitly parses /etc/locale.conf
(or some other system-wide configurtion file) and overwrites the environment variables with those values instead honoring what is already set.