Load the language from AccountsService if available

This commit is contained in:
Anthony Rose 2021-02-10 00:11:02 +00:00
parent 270be39c68
commit 86f2a1fbfa

View file

@ -53,7 +53,25 @@ set -o noclobber
export LC_ALL=''
export TIME_STYLE="long-iso" # Used by GNU 'ls'.
## Set the default language.
if [ -r "$HOME/.config/user-dirs.locale" ]; then
acctsvclang=$(dbus-send \
--system \
--print-reply=literal \
--dest=org.freedesktop.Accounts \
$(dbus-send \
--system \
--print-reply=literal \
--dest=org.freedesktop.Accounts \
--type=method_call \
/org/freedesktop/Accounts \
org.freedesktop.Accounts.FindUserById int64:$(id -u)) \
org.freedesktop.DBus.Properties.Get \
string:org.freedesktop.Accounts.User \
string:Language \
2>/dev/null \
| awk '{print $2}')
if [ -n "$acctsvclang" ]; then
LANG=$acctsvclang
elif [ -r "$HOME/.config/user-dirs.locale" ]; then
LANG="$(cat $HOME/.config/user-dirs.locale).UTF-8"
elif [ -r "$HOME/.config/locale.conf" ]; then
. "$HOME/.config/locale.conf"