You are not logged in.

#1 2020-04-12 15:51:23

Fofeu
Member
Registered: 2020-04-12
Posts: 2

LightDM seems to preset a locale

Hello,

I recently changed locale on my setup (from fr_FR.utf8 to en_GB.utf8) and for some unknown reason, the original locale seemed to be forced.

I could track to problem to $LANG being set before the Xsession-wrapper was loaded, thus disabling the logic in /etc/profile.d/locale.sh.
Temporarily, I disabled the $LANG check in /etc/profile.d/locale.sh which forces the new locale.
However, I would prefer a clean solution, but I am unable to find where the environment variable is set.
I grep-ed /etc and /boot but there weren't any sensible matches for either "fr_FR" or "LANG"

Does anyone have any clue ?

Offline

#2 2020-04-12 15:54:18

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: LightDM seems to preset a locale

I'm not sure what "locale seemed to be forced" means other than it's your interpretation of some symptom.  Please post actual symptoms and diagnostics: how did you track it to LANG being set?


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2020-04-12 16:17:22

Fofeu
Member
Registered: 2020-04-12
Posts: 2

Re: LightDM seems to preset a locale

Here are the symptoms:

  • /etc/locale.conf contains exclusively "LANG=en_GB.UTF-8"

  • Inside a user session, LANG is set to "fr_FR.utf8" and calling `locale` shows all environment variables as set to "fr_FR.utf8"

Here are my diagnostics:
I wrote a wrapper to log the output of /etc/lightdm/Xsession and added traces to track the evolution of $LANG.

There, I could see that the $LANG is set to "fr_FR.utf8" before bash evaluates /etc/lightdm/Xsession.
This file is supposed to load /etc/profile which uses /etc/locale.conf and/or $XDG_CONFIG_HOME/locale.conf to set the locale, but only if $LANG isn't set.

Because I don't know what is loaded before /etc/lightdm/Xsession, I removed the check verifying that $LANG isn't set in /etc/profile temporarely.

Should I add any details ?

Offline

#4 2020-04-12 16:23:41

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: LightDM seems to preset a locale

Have you added your new locale to /etc/locale.gen and re-run locale-gen?

This may also be relevant, though that would seem to side-step the problem rather than fix it.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2021-01-17 11:35:52

prasselpikachu
Member
Registered: 2015-03-10
Posts: 3

Re: LightDM seems to preset a locale

I'm also running into the same problem. To diagnose, I wrote a tiny script that dumps $LANG into a file in /tmp, and made the lightdm execute it instead of lightdm with an override.

After starting the system like that once, I could see from the file that $LANG is set to what's in /etc/locale.conf when starting lightdm.
When /etc/profile.d/locale.sh is executed by LightDM, $LANG is still set, so it completely ignores ~/.config/locale.conf.

I decided to dig into its source code a bit and I found a way to set $LANG through a LightDM config file, but it doesn't work yet for some reason.

There's a file called ~/.dmrc, which usually just stores the last session you were using. It's an INI format, and with Plasma as the last session, it would look like this:

[Desktop]
Session=plasma

You can find all parameters read from the file here: https://github.com/canonical/lightdm/bl … st.c#L1183

As you can see, there is a 'Language' key. Going through the code base, you can see how it should be formatted here: https://github.com/canonical/lightdm/bl … st.c#L1313 (no big surprise, it's just getting passed on without any modifications, so exactly what you would write into $LANG)

And here it's set for the session being started: https://github.com/canonical/lightdm/bl … eat.c#L990

So I added a 'Language=de_DE.UTF-8' line to my ~/.dmrc, restarted my session, but nothing changed, even though LightDM should now set $LANG based on that.

I'll investigate further, and give an update.

Offline

#6 2021-01-17 15:12:13

prasselpikachu
Member
Registered: 2015-03-10
Posts: 3

Re: LightDM seems to preset a locale

Okay, found out more.

In my case, I had 'accountsservice' installed as a dependency of plasma-desktop. If you have this package installed, there will be a D-Bus interface for querying user information (like the last session for example). If LightDM sees you're running AccountsService, it will not load any values from .dmrc: https://github.com/canonical/lightdm/bl … st.c#L1171

Setting the language in AccountsService works through D-Bus and is relatively easy:

busctl call org.freedesktop.Accounts /org/freedesktop/Accounts/User1000 org.freedesktop.Accounts.User SetLanguage s "de_DE.UTF-8"

Alternatively, you could add a line "Language=de_DE.UTF-8" to /var/lib/AccountsService/users/<your_username>, this is where AccountsService would save the configuration if you talk to it over D-Bus.

After running the busctl command and logging in again, LANG was set correctly.

I did have a small issue with Plasma (KDE) locking its locale in ~/.config/plasma-localerc - the wiki helped me out there: https://wiki.archlinux.org/index.php/KD … e_settings

Also, Firefox needed the appropriate language pack and wouldn't pick up the new locale either. It has its own language settings though, where setting the correct language will also work. I suspect it would also look at $LANG if you threw away your Firefox profile and started it again (like a first start, i guess), kind of like Plasma does it. There's probably some reasoning behind this, but I'm not going to dig through another two codebases for definitive answers ;)

Last edited by prasselpikachu (2021-01-17 15:58:34)

Offline

Board footer

Powered by FluxBB