|
2 | 2 | import sys |
3 | 3 | import time |
4 | 4 |
|
| 5 | +from archinstall.default_profiles.profile import GreeterType |
5 | 6 | from archinstall.lib.applications.application_handler import ApplicationHandler |
6 | 7 | from archinstall.lib.args import ArchConfig, ArchConfigHandler |
7 | 8 | from archinstall.lib.authentication.authentication_handler import AuthenticationHandler |
|
11 | 12 | from archinstall.lib.general.general_menu import PostInstallationAction, select_post_installation |
12 | 13 | from archinstall.lib.global_menu import GlobalMenu |
13 | 14 | from archinstall.lib.installer import Installer, accessibility_tools_in_use, run_custom_user_commands |
| 15 | +from archinstall.lib.menu.helpers import Confirmation |
14 | 16 | from archinstall.lib.menu.util import delayed_warning |
15 | 17 | from archinstall.lib.mirror.mirror_handler import MirrorListHandler |
16 | 18 | from archinstall.lib.models import Bootloader |
|
24 | 26 | from archinstall.tui.ui.components import tui |
25 | 27 |
|
26 | 28 |
|
| 29 | +def _has_greeter_without_user(config: ArchConfig) -> bool: |
| 30 | + """Check if the user selected a desktop with a greeter that can't log in without a regular user.""" |
| 31 | + profile_config = config.profile_config |
| 32 | + if not profile_config or not profile_config.profile: |
| 33 | + return False |
| 34 | + |
| 35 | + if not profile_config.profile.is_desktop_profile(): |
| 36 | + return False |
| 37 | + |
| 38 | + has_users = config.auth_config and config.auth_config.users |
| 39 | + if has_users: |
| 40 | + return False |
| 41 | + |
| 42 | + # These greeters only show users with UID >= 1000 and have no manual login by default |
| 43 | + problematic_greeters = {GreeterType.Sddm} |
| 44 | + |
| 45 | + return any(p.default_greeter_type in problematic_greeters for p in profile_config.profile.current_selection) |
| 46 | + |
| 47 | + |
| 48 | +async def _warn_greeter_no_user() -> bool: |
| 49 | + prompt = ( |
| 50 | + 'The desktop profile you have selected needs a regular user created to log in. ' |
| 51 | + 'One has not been created. ' |
| 52 | + 'Would you like to continue without a regular user?\n' |
| 53 | + ) |
| 54 | + |
| 55 | + result = await Confirmation(header=prompt, allow_skip=False, preset=False).show() |
| 56 | + return result.get_value() |
| 57 | + |
| 58 | + |
27 | 59 | def show_menu( |
28 | 60 | arch_config_handler: ArchConfigHandler, |
29 | 61 | mirror_list_handler: MirrorListHandler, |
@@ -223,6 +255,10 @@ def main(arch_config_handler: ArchConfigHandler | None = None) -> None: |
223 | 255 | debug('Installation aborted') |
224 | 256 | aborted = True |
225 | 257 |
|
| 258 | + if not aborted and _has_greeter_without_user(arch_config_handler.config): |
| 259 | + if not tui.run(_warn_greeter_no_user): |
| 260 | + aborted = True |
| 261 | + |
226 | 262 | if aborted: |
227 | 263 | return main(arch_config_handler) |
228 | 264 |
|
|
0 commit comments