You are not logged in.

#1 2023-03-16 08:59:27

sigboe
Member
Registered: 2023-01-02
Posts: 7

Cant set LC_TIME

Hello,

I can't set LC_TIME, and its driving me a bit nuts. Here is what happens when I run /etc/profile.d/locale.sh with the setting to print each line it executes. You can see when the script which should set LC_TIME is sourcing the locale.conf it just reads LANG and not LC_TIME

% sh -x /etc/profile.d/locale.sh 
+ '[' -z en_US.UTF-8 ']'
+ LANG=en_US.UTF-8
+ export LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION

My /etc/locale.conf file

LANG=en_US.UTF-8
LC_TIME=nb_NO.UTF-8

output of locale -a

% locale -a
bokmal
C
C.UTF-8
en_US.utf8
nb_NO
nb_NO.iso88591
nb_NO.utf8
no_NO
no_NO.ISO-8859-1
norwegian
POSIX

Output of locale

% locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

Please help what to check for....


EDIT:

Just trying to launch sh which is the shebang in /etc/profile.d/locale.conf and setting set -x and souring the file, it does source both lines, but not inside the script that is run when the profile is set up

% sh
sh-5.1$ set -x
sh-5.1$ . /etc/locale.conf 
+ . /etc/locale.conf
++ LANG=en_US.UTF-8
++ LC_TIME=nb_NO.UTF-8

EDIT 2:

Oh I see now, /etc/profile.d/locale.conf doesn't set LC_TIME because LANG is already set prior to running the script.  Maybe this is also happening before the profile is set up at login? Where can I look for other places LANG is set before the profile is configured at login?

Last edited by sigboe (2023-03-16 09:10:20)

Offline

#2 2023-03-16 09:34:43

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: Cant set LC_TIME

sigboe wrote:

Where can I look for other places LANG is set before the profile is configured at login?

Read the comments at the top of /etc/profile.d/locale.sh?

Setting this locale variable can be done as follows:

localectl set-locale LC_TIME=nb_NO.UTF-8

This (AFAIK) updates locale.conf and sets LC_TIME in the environment of the system manager as if by

systemctl set-environment LC_TIME=nb_NO.UTF-8

This updated environment should then be inherited by newly started services and user sessions. See also https://wiki.archlinux.org/title/Locale … _immediate

Last edited by Raynman (2023-03-16 09:35:53)

Offline

#3 2023-03-16 12:48:11

sigboe
Member
Registered: 2023-01-02
Posts: 7

Re: Cant set LC_TIME

Raynman wrote:
sigboe wrote:

Where can I look for other places LANG is set before the profile is configured at login?

Read the comments at the top of /etc/profile.d/locale.sh?

Setting this locale variable can be done as follows:

localectl set-locale LC_TIME=nb_NO.UTF-8

This (AFAIK) updates locale.conf and sets LC_TIME in the environment of the system manager as if by

systemctl set-environment LC_TIME=nb_NO.UTF-8

This updated environment should then be inherited by newly started services and user sessions. See also https://wiki.archlinux.org/title/Locale … _immediate

Hello and thank you so much for your suggestions

I have tried these commands as root, (and the first one also as user), and it works in a shell if I follow the instructions to make locale changes immediate. But it doesn't function systemwide, nor does it work after a reboot/relogin

Is there suggestions how  I can figure out why this does not work? It works fine on my desktop, only my laptop it doesn't work.

Offline

#4 2023-03-16 13:15:07

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: Cant set LC_TIME

I got the impression you didn't want to reboot, because you were only talking about login. A reboot should lead to changes in locale.conf being picked up without needing other commands to manipulate environments.

I assume "it doesn't work" means the output of `locale` is still the same as in the OP? Are you using a desktop environment? They usually want to control these things and may override system-wide settings. And there's always a chance you put something in a (shell) startup/initialization file (.bash_rc/.bash_profile/.xinitrc/...) and forgot about it. You could (sanity-)check `systemctl show-environment` and `localectl` after (re)boot to see if the LC_TIME from locale.conf is at least visible there.

Offline

#5 2023-03-17 08:13:09

sigboe
Member
Registered: 2023-01-02
Posts: 7

Re: Cant set LC_TIME

Raynman wrote:

I got the impression you didn't want to reboot, because you were only talking about login. A reboot should lead to changes in locale.conf being picked up without needing other commands to manipulate environments.

I assume "it doesn't work" means the output of `locale` is still the same as in the OP? Are you using a desktop environment? They usually want to control these things and may override system-wide settings. And there's always a chance you put something in a (shell) startup/initialization file (.bash_rc/.bash_profile/.xinitrc/...) and forgot about it. You could (sanity-)check `systemctl show-environment` and `localectl` after (re)boot to see if the LC_TIME from locale.conf is at least visible there.

I am having the same issue with Sway and i3, I have no aversion to reboots, I want it to be set in the environment and not just a shell. Since I want time settings for calendars and such. Thank you!

Offline

Board footer

Powered by FluxBB