init console fonts
This commit is contained in:
parent
cd62eff4a7
commit
27e8b23637
|
|
@ -927,6 +927,11 @@ class Installer:
|
|||
|
||||
if locale_config:
|
||||
self.set_vconsole(locale_config)
|
||||
# fonts that are in the ISO but not on target
|
||||
# unless we specifically request it before base
|
||||
# otherwise mkinitcpio will be screaming at you
|
||||
if locale_config.console_font.startswith('ter-'):
|
||||
self._base_packages.append('terminus-font')
|
||||
|
||||
self.pacman.strap(self._base_packages)
|
||||
self._helper_flags['base-strapped'] = True
|
||||
|
|
@ -1979,23 +1984,14 @@ class Installer:
|
|||
return False
|
||||
|
||||
def set_vconsole(self, locale_config: LocaleConfiguration) -> None:
|
||||
# use the already set kb layout
|
||||
kb_vconsole: str = locale_config.kb_layout
|
||||
# this is the default used in ISO other option for hdpi screens TER16x32
|
||||
# can be checked using
|
||||
# zgrep "CONFIG_FONT" /proc/config.gz
|
||||
# https://wiki.archlinux.org/title/Linux_console#Fonts
|
||||
font_vconsole: str = locale_config.console_font
|
||||
|
||||
font_vconsole = 'default8x16'
|
||||
|
||||
# Ensure /etc exists
|
||||
vconsole_dir: Path = self.target / 'etc'
|
||||
vconsole_dir.mkdir(parents=True, exist_ok=True)
|
||||
vconsole_path: Path = vconsole_dir / 'vconsole.conf'
|
||||
|
||||
# Write both KEYMAP and FONT to vconsole.conf
|
||||
vconsole_content = f'KEYMAP={kb_vconsole}\n'
|
||||
# Corrects another warning
|
||||
vconsole_content += f'FONT={font_vconsole}\n'
|
||||
|
||||
vconsole_path.write_text(vconsole_content)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from typing import override
|
||||
|
||||
from archinstall.lib.locale.utils import list_keyboard_languages, list_locales, set_kb_layout
|
||||
from archinstall.lib.locale.utils import list_console_fonts, list_keyboard_languages, list_locales, set_kb_layout
|
||||
from archinstall.lib.menu.abstract_menu import AbstractSubMenu
|
||||
from archinstall.lib.menu.helpers import Selection
|
||||
from archinstall.lib.models.locale import LocaleConfiguration
|
||||
|
|
@ -47,6 +47,13 @@ class LocaleMenu(AbstractSubMenu[LocaleConfiguration]):
|
|||
preview_action=lambda item: item.get_value(),
|
||||
key='sys_enc',
|
||||
),
|
||||
MenuItem(
|
||||
text=tr('Console font'),
|
||||
action=select_console_font,
|
||||
value=self._locale_conf.console_font,
|
||||
preview_action=lambda item: item.get_value(),
|
||||
key='console_font',
|
||||
),
|
||||
]
|
||||
|
||||
@override
|
||||
|
|
@ -140,3 +147,25 @@ async def select_kb_layout(preset: str | None = None) -> str | None:
|
|||
return preset
|
||||
case _:
|
||||
raise ValueError('Unhandled return type')
|
||||
|
||||
async def select_console_font(preset: str | None = None) -> str | None:
|
||||
fonts = list_console_fonts()
|
||||
|
||||
items = [MenuItem(f, value=f) for f in fonts]
|
||||
group = MenuItemGroup(items, sort_items=False)
|
||||
group.set_focus_by_value(preset)
|
||||
|
||||
result = SelectMenu[str](
|
||||
group,
|
||||
alignment=Alignment.CENTER,
|
||||
frame=FrameProperties.min(tr('Console font')),
|
||||
allow_skip=True,
|
||||
).run()
|
||||
|
||||
match result.type_:
|
||||
case ResultType.Selection:
|
||||
return result.get_value()
|
||||
case ResultType.Skip:
|
||||
return preset
|
||||
case _:
|
||||
raise ValueError('Unhandled return type')
|
||||
|
|
@ -109,3 +109,15 @@ def list_timezones() -> list[str]:
|
|||
.decode()
|
||||
.splitlines()
|
||||
)
|
||||
|
||||
def list_console_fonts() -> list[str]:
|
||||
fonts: list[str] = []
|
||||
font_dir = Path('/usr/share/kbd/consolefonts')
|
||||
if font_dir.exists():
|
||||
for f in font_dir.iterdir():
|
||||
# do not ask me there are readme files in here
|
||||
if not f.name.startswith('README'):
|
||||
name = f.name.removesuffix('.gz').removesuffix('.psfu').removesuffix('.psf')
|
||||
fonts.append(name)
|
||||
|
||||
return sorted(fonts, key=lambda x: (len(x), x))
|
||||
|
|
@ -10,6 +10,7 @@ class LocaleConfiguration:
|
|||
kb_layout: str
|
||||
sys_lang: str
|
||||
sys_enc: str
|
||||
console_font: str = 'default8x16'
|
||||
|
||||
@classmethod
|
||||
def default(cls) -> Self:
|
||||
|
|
@ -23,12 +24,14 @@ class LocaleConfiguration:
|
|||
'kb_layout': self.kb_layout,
|
||||
'sys_lang': self.sys_lang,
|
||||
'sys_enc': self.sys_enc,
|
||||
'console_font': self.console_font,
|
||||
}
|
||||
|
||||
def preview(self) -> str:
|
||||
output = '{}: {}\n'.format(tr('Keyboard layout'), self.kb_layout)
|
||||
output += '{}: {}\n'.format(tr('Locale language'), self.sys_lang)
|
||||
output += '{}: {}'.format(tr('Locale encoding'), self.sys_enc)
|
||||
output += '{}: {}'.format(tr('Console font'), self.console_font)
|
||||
return output
|
||||
|
||||
def _load_config(self, args: dict[str, str]) -> None:
|
||||
|
|
@ -38,6 +41,8 @@ class LocaleConfiguration:
|
|||
self.sys_enc = args['sys_enc']
|
||||
if 'kb_layout' in args:
|
||||
self.kb_layout = args['kb_layout']
|
||||
if 'console_font' in args:
|
||||
self.console_font = args['console_font']
|
||||
|
||||
@classmethod
|
||||
def parse_arg(cls, args: dict[str, Any]) -> Self:
|
||||
|
|
|
|||
Loading…
Reference in New Issue