Skip to content

Commit 0d58f9b

Browse files
committed
Warn when a desktop profile's greeter can't log in without a regular user
1 parent 398d6cf commit 0d58f9b

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

archinstall/scripts/guided.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import sys
33
import time
44

5+
from archinstall.default_profiles.profile import GreeterType
56
from archinstall.lib.applications.application_handler import ApplicationHandler
67
from archinstall.lib.args import ArchConfig, ArchConfigHandler
78
from archinstall.lib.authentication.authentication_handler import AuthenticationHandler
@@ -11,6 +12,7 @@
1112
from archinstall.lib.general.general_menu import PostInstallationAction, select_post_installation
1213
from archinstall.lib.global_menu import GlobalMenu
1314
from archinstall.lib.installer import Installer, accessibility_tools_in_use, run_custom_user_commands
15+
from archinstall.lib.menu.helpers import Confirmation
1416
from archinstall.lib.menu.util import delayed_warning
1517
from archinstall.lib.mirror.mirror_handler import MirrorListHandler
1618
from archinstall.lib.models import Bootloader
@@ -24,6 +26,36 @@
2426
from archinstall.tui.ui.components import tui
2527

2628

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+
2759
def show_menu(
2860
arch_config_handler: ArchConfigHandler,
2961
mirror_list_handler: MirrorListHandler,
@@ -223,6 +255,10 @@ def main(arch_config_handler: ArchConfigHandler | None = None) -> None:
223255
debug('Installation aborted')
224256
aborted = True
225257

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+
226262
if aborted:
227263
return main(arch_config_handler)
228264

0 commit comments

Comments
 (0)