Improve compatibility with bleeding edge Linux distributions

This commit is contained in:
codeking 2025-08-08 19:28:11 +02:00
parent 08c1c8c7c3
commit 260a13c380

View file

@ -40,15 +40,34 @@ class ApplicationController:
if not os.path.isdir(persistent_state_path) or len(os.listdir(persistent_state_path)) == 0: if not os.path.isdir(persistent_state_path) or len(os.listdir(persistent_state_path)) == 0:
shutil.copytree(f'{version.get_installation_path()}/resources/initial-state', persistent_state_path) shutil.copytree(f'{version.get_installation_path()}/resources/initial-state', persistent_state_path)
if (not os.path.isdir(font_path) or len(os.listdir(font_path)) == 0) and os.path.isdir('/usr/share/fonts/truetype'): if (not os.path.isdir(font_path) or len(os.listdir(font_path)) == 0) and os.path.isdir('/usr/share/fonts'):
font_families = [file.name for file in Path('/usr/share/fonts/truetype').iterdir() if file.is_dir()] if os.path.isdir('/usr/share/fonts/truetype'):
preferred_font_families = ['dejavu', 'droid', 'liberation', 'libreoffice', 'noto', 'ubuntu'] truetype_fonts_path = '/usr/share/fonts/truetype'
else:
truetype_fonts_path = '/usr/share/fonts'
font_families = [file.name for file in Path(truetype_fonts_path).iterdir() if file.is_dir()]
preferred_font_families = [
'adwaita-sans-fonts',
'dejavu',
'droid',
'google-droid-sans-fonts',
'google-noto-sans-cjk-vf-fonts',
'google-noto-sans-mono-cjk-vf-fonts',
'liberation',
'liberation-sans-fonts',
'libreoffice',
'noto',
'open-sans',
'ubuntu'
]
font_family_subset = ApplicationController.__select_random_subset(font_families, preferred_font_families, 12) font_family_subset = ApplicationController.__select_random_subset(font_families, preferred_font_families, 12)
for font_family in font_family_subset: for font_family in font_family_subset:
shutil.copytree(f'/usr/share/fonts/truetype/{font_family}', f'{font_path}/{font_family}') shutil.copytree(f'{truetype_fonts_path}/{font_family}', f'{font_path}/{font_family}')
display = ApplicationController.__find_unused_display() display = ApplicationController.__find_unused_display()
time_zone = profile.determine_timezone() time_zone = profile.determine_timezone()