1+ from enum import StrEnum
12from typing import override
23
3- from archinstall .default_profiles .profile import DisplayServerType , GreeterType , Profile , ProfileType
4+ from archinstall .default_profiles .profile import CustomSetting , DisplayServerType , GreeterType , Profile , ProfileType
5+ from archinstall .lib .menu .helpers import Selection
6+ from archinstall .lib .packages .packages import available_package , package_group_info
7+ from archinstall .lib .translationhandler import tr
8+ from archinstall .tui .ui .menu_item import MenuItem , MenuItemGroup
9+ from archinstall .tui .ui .result import ResultType
10+
11+
12+ class PlasmaFlavor (StrEnum ):
13+ Meta = 'plasma-meta'
14+ Plasma = 'plasma'
15+ Desktop = 'plasma-desktop'
16+
17+ def show (self ) -> str :
18+ match self :
19+ case PlasmaFlavor .Meta :
20+ return f'{ self .value } ({ tr ("Recommended" )} )'
21+ case PlasmaFlavor .Plasma | PlasmaFlavor .Desktop :
22+ return self .value
23+
24+ def package_details (self ) -> str :
25+ ty = ''
26+ details = ''
27+ desc = ''
28+
29+ match self :
30+ case PlasmaFlavor .Meta :
31+ ty = tr ('Package' )
32+ desc = tr ('Curated selection of KDE Plasma packages' )
33+ info = available_package (self .value )
34+
35+ if info is not None :
36+ details = tr ('Dependencies' ) + '\n '
37+ details += '\n ' .join (f'- { entry } ' for entry in info .get_depends_on )
38+ case PlasmaFlavor .Plasma :
39+ ty = tr ('Package group' )
40+ desc = tr ('Extensive KDE Plasma installation' )
41+ group = package_group_info (self .value )
42+
43+ if group is not None :
44+ details = tr ('Packages in group' ) + '\n '
45+ details += '\n ' .join (f'- { entry } ' for entry in group .packages )
46+ case PlasmaFlavor .Desktop :
47+ ty = tr ('Package group' )
48+ desc = tr ('Minimal KDE Plasma installation' )
49+ info = available_package (self .value )
50+
51+ if info is not None :
52+ details = tr ('Dependencies' ) + '\n '
53+ details += '\n ' .join (f'- { entry } ' for entry in info .get_depends_on )
54+
55+ return f'{ tr ("Type" )} : { ty } \n { tr ("Description" )} : { desc } \n \n { details } '
56+
57+ def packages (self ) -> list [str ]:
58+ match self :
59+ case PlasmaFlavor .Meta :
60+ return ['plasma-meta' ]
61+ case PlasmaFlavor .Plasma :
62+ return ['plasma' ]
63+ case PlasmaFlavor .Desktop :
64+ return ['plasma-desktop' ]
465
566
667class PlasmaProfile (Profile ):
@@ -15,18 +76,45 @@ def __init__(self) -> None:
1576 @property
1677 @override
1778 def packages (self ) -> list [str ]:
18- return [
19- 'plasma-desktop' ,
20- 'kscreen' ,
21- 'plasma-pa' ,
22- 'konsole' ,
23- 'kate' ,
24- 'dolphin' ,
25- 'ark' ,
26- 'plasma-workspace' ,
27- ]
79+ flavor_str = self .custom_settings .get (CustomSetting .PlasmaFlavor )
80+
81+ if flavor_str is not None :
82+ flavor = PlasmaFlavor (flavor_str )
83+ return flavor .packages ()
84+ else :
85+ return PlasmaFlavor .Meta .packages () # use plasma-meta as the recommended default
2886
2987 @property
3088 @override
3189 def default_greeter_type (self ) -> GreeterType :
3290 return GreeterType .PlasmaLoginManager
91+
92+ async def _select_flavor (self ) -> None :
93+ header = tr ('Select a flavor of KDE Plasma to install' ) + '\n '
94+
95+ items = [
96+ MenuItem (
97+ s .show (),
98+ value = s ,
99+ preview_action = lambda x : x .value .package_details () if x .value else None ,
100+ )
101+ for s in PlasmaFlavor
102+ ]
103+ group = MenuItemGroup (items , sort_items = False )
104+
105+ default = self .custom_settings .get (CustomSetting .PlasmaFlavor , None )
106+ group .set_default_by_value (default )
107+
108+ result = await Selection [PlasmaFlavor ](
109+ group ,
110+ header = header ,
111+ allow_skip = False ,
112+ preview_location = 'right' ,
113+ ).show ()
114+
115+ if result .type_ == ResultType .Selection :
116+ self .custom_settings [CustomSetting .PlasmaFlavor ] = result .get_value ().value
117+
118+ @override
119+ async def do_on_select (self ) -> None :
120+ await self ._select_flavor ()
0 commit comments