diff --git a/archinstall/__init__.py b/archinstall/__init__.py index aa644d48b2..6d0853c259 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -32,7 +32,11 @@ from .lib.profiles import * from .lib.services import * from .lib.storage import * -from .lib.systemd import * +from .lib.systemd import ( + localectl_status, + Boot, + Ini +) from .lib.user_interaction import * from .lib.menu import Menu from .lib.menu.list_manager import ListManager diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index b0f7ac3272..5afa10bb35 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -1056,6 +1056,8 @@ def create_file(self, filename :str, owner :Optional[str] = None) -> Installatio return InstallationFile(self, filename, owner) def set_keyboard_language(self, language: str) -> bool: + from .systemd import localectl_status + log(f"Setting keyboard language to {language}", level=logging.INFO) if len(language.strip()): if not verify_keyboard_layout(language): @@ -1075,6 +1077,16 @@ def set_keyboard_language(self, language: str) -> bool: else: self.log('Keyboard language was not changed from default (no language specified).', fg="yellow", level=logging.INFO) + # This needs to be explicitly set in some cases due to https://github.com/archlinux/archinstall/issues/596 + if LANG := localectl_status().get('x11_layout'): + with open(f"{self.target}/etc/vconsole.conf", "a") as vconsole: + with open(f'{self.target}/etc/locale.conf', 'r') as locale: + locale_data = locale.read() + + # TODO: A bit of a hack to convert LANG=en_US.UTF-8 into just US.UTF-8 + locale_and_encoding = locale_data.split('=', 1)[1].split('_', 1)[1] + vconsole.write(f"LANG={LANG}_{locale_and_encoding}\n") + return True def set_x11_keyboard_language(self, language: str) -> bool: diff --git a/archinstall/lib/systemd.py b/archinstall/lib/systemd.py index 417870da49..55e716ba3c 100644 --- a/archinstall/lib/systemd.py +++ b/archinstall/lib/systemd.py @@ -138,3 +138,11 @@ def SysCommandWorker(self, cmd: list, *args, **kwargs) -> SysCommandWorker: cmd[0] = locate_binary(cmd[0]) return SysCommandWorker(["systemd-run", f"--machine={self.container_name}", "--pty", *cmd], *args, **kwargs) + +def localectl_status(): + result = {} + for line in SysCommand(["localectl", "status"]): + key, value = line.strip().decode('UTF-8').split(': ', 1) + result[key.lower().replace(' ', '_')] = value + + return result \ No newline at end of file diff --git a/examples/guided.py b/examples/guided.py index f104b7e36b..29d6e9a773 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -254,6 +254,10 @@ def perform_installation(mountpoint): if archinstall.arguments.get('custom-commands', None): archinstall.run_custom_user_commands(archinstall.arguments['custom-commands'], installation) + # After certain locale's has been set, this needs + # to be re-run to avoid issues such as https://github.com/archlinux/archinstall/issues/596 + installation.mkinitcpio('-P') + installation.log("For post-installation tips, see https://wiki.archlinux.org/index.php/Installation_guide#Post-installation", fg="yellow") if not archinstall.arguments.get('silent'): prompt = str(_('Would you like to chroot into the newly created installation and perform post-installation configuration?'))