Skip to content

Commit ba5a190

Browse files
committed
Flexible plasma profile selection
1 parent d57709c commit ba5a190

7 files changed

Lines changed: 115 additions & 58 deletions

File tree

archinstall/default_profiles/desktops/hyprland.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import override
22

33
from archinstall.default_profiles.desktops import SeatAccess
4-
from archinstall.default_profiles.profile import DisplayServerType, GreeterType, Profile, ProfileType
4+
from archinstall.default_profiles.profile import CustomSetting, DisplayServerType, GreeterType, Profile, ProfileType
55
from archinstall.lib.menu.helpers import Selection
66
from archinstall.lib.translationhandler import tr
77
from archinstall.tui.ui.menu_item import MenuItem, MenuItemGroup
@@ -17,7 +17,7 @@ def __init__(self) -> None:
1717
display_server=DisplayServerType.Wayland,
1818
)
1919

20-
self.custom_settings = {'seat_access': None}
20+
self.custom_settings = {CustomSetting.SeatAccess: None}
2121

2222
@property
2323
@override
@@ -45,7 +45,7 @@ def default_greeter_type(self) -> GreeterType:
4545
@property
4646
@override
4747
def services(self) -> list[str]:
48-
if pref := self.custom_settings.get('seat_access', None):
48+
if pref := self.custom_settings.get(CustomSetting.SeatAccess, None):
4949
return [pref]
5050
return []
5151

@@ -57,7 +57,7 @@ async def _select_seat_access(self) -> None:
5757
items = [MenuItem(s.value, value=s) for s in SeatAccess]
5858
group = MenuItemGroup(items, sort_items=True)
5959

60-
default = self.custom_settings.get('seat_access', None)
60+
default = self.custom_settings.get(CustomSetting.SeatAccess, None)
6161
group.set_default_by_value(default)
6262

6363
result = await Selection[SeatAccess](
@@ -67,7 +67,7 @@ async def _select_seat_access(self) -> None:
6767
).show()
6868

6969
if result.type_ == ResultType.Selection:
70-
self.custom_settings['seat_access'] = result.get_value().value
70+
self.custom_settings[CustomSetting.SeatAccess] = result.get_value().value
7171

7272
@override
7373
async def do_on_select(self) -> None:

archinstall/default_profiles/desktops/labwc.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import override
22

33
from archinstall.default_profiles.desktops import SeatAccess
4-
from archinstall.default_profiles.profile import DisplayServerType, GreeterType, Profile, ProfileType
4+
from archinstall.default_profiles.profile import CustomSetting, DisplayServerType, GreeterType, Profile, ProfileType
55
from archinstall.lib.menu.helpers import Selection
66
from archinstall.lib.translationhandler import tr
77
from archinstall.tui.ui.menu_item import MenuItem, MenuItemGroup
@@ -17,13 +17,13 @@ def __init__(self) -> None:
1717
display_server=DisplayServerType.Wayland,
1818
)
1919

20-
self.custom_settings = {'seat_access': None}
20+
self.custom_settings = {CustomSetting.SeatAccess: None}
2121

2222
@property
2323
@override
2424
def packages(self) -> list[str]:
2525
additional = []
26-
if seat := self.custom_settings.get('seat_access', None):
26+
if seat := self.custom_settings.get(CustomSetting.SeatAccess, None):
2727
additional = [seat]
2828

2929
return [
@@ -39,7 +39,7 @@ def default_greeter_type(self) -> GreeterType:
3939
@property
4040
@override
4141
def services(self) -> list[str]:
42-
if pref := self.custom_settings.get('seat_access', None):
42+
if pref := self.custom_settings.get(CustomSetting.SeatAccess, None):
4343
return [pref]
4444
return []
4545

@@ -51,7 +51,7 @@ async def _select_seat_access(self) -> None:
5151
items = [MenuItem(s.value, value=s) for s in SeatAccess]
5252
group = MenuItemGroup(items, sort_items=True)
5353

54-
default = self.custom_settings.get('seat_access', None)
54+
default = self.custom_settings.get(CustomSetting.SeatAccess, None)
5555
group.set_default_by_value(default)
5656

5757
result = await Selection[SeatAccess](
@@ -61,7 +61,7 @@ async def _select_seat_access(self) -> None:
6161
).show()
6262

6363
if result.type_ == ResultType.Selection:
64-
self.custom_settings['seat_access'] = result.get_value().value
64+
self.custom_settings[CustomSetting.SeatAccess] = result.get_value().value
6565

6666
@override
6767
async def do_on_select(self) -> None:

archinstall/default_profiles/desktops/niri.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import override
22

33
from archinstall.default_profiles.desktops import SeatAccess
4-
from archinstall.default_profiles.profile import DisplayServerType, GreeterType, Profile, ProfileType
4+
from archinstall.default_profiles.profile import CustomSetting, DisplayServerType, GreeterType, Profile, ProfileType
55
from archinstall.lib.menu.helpers import Selection
66
from archinstall.lib.translationhandler import tr
77
from archinstall.tui.ui.menu_item import MenuItem, MenuItemGroup
@@ -17,13 +17,13 @@ def __init__(self) -> None:
1717
display_server=DisplayServerType.Wayland,
1818
)
1919

20-
self.custom_settings = {'seat_access': None}
20+
self.custom_settings = {CustomSetting.SeatAccess: None}
2121

2222
@property
2323
@override
2424
def packages(self) -> list[str]:
2525
additional = []
26-
if seat := self.custom_settings.get('seat_access', None):
26+
if seat := self.custom_settings.get(CustomSetting.SeatAccess, None):
2727
additional = [seat]
2828

2929
return [
@@ -47,7 +47,7 @@ def default_greeter_type(self) -> GreeterType:
4747
@property
4848
@override
4949
def services(self) -> list[str]:
50-
if pref := self.custom_settings.get('seat_access', None):
50+
if pref := self.custom_settings.get(CustomSetting.SeatAccess, None):
5151
return [pref]
5252
return []
5353

@@ -59,7 +59,7 @@ async def _select_seat_access(self) -> None:
5959
items = [MenuItem(s.value, value=s) for s in SeatAccess]
6060
group = MenuItemGroup(items, sort_items=True)
6161

62-
default = self.custom_settings.get('seat_access', None)
62+
default = self.custom_settings.get(CustomSetting.SeatAccess, None)
6363
group.set_default_by_value(default)
6464

6565
result = await Selection[SeatAccess](
@@ -69,7 +69,7 @@ async def _select_seat_access(self) -> None:
6969
).show()
7070

7171
if result.type_ == ResultType.Selection:
72-
self.custom_settings['seat_access'] = result.get_value().value
72+
self.custom_settings[CustomSetting.SeatAccess] = result.get_value().value
7373

7474
@override
7575
async def do_on_select(self) -> None:
Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,30 @@
1+
from enum import Enum
12
from 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.translationhandler import tr
7+
from archinstall.tui.ui.menu_item import MenuItem, MenuItemGroup
8+
from archinstall.tui.ui.result import ResultType
9+
10+
11+
class PlasmaFlavor(Enum):
12+
Plasma = 'plasma'
13+
Meta = 'plasma-meta'
14+
Desktop = 'plasma-desktop'
15+
16+
def show(self) -> str:
17+
match self:
18+
case PlasmaFlavor.Plasma:
19+
desc = tr('Extensive KDE Plasma installation')
20+
case PlasmaFlavor.Meta:
21+
desc = tr('Curated selection of KDE Plasma packages')
22+
case PlasmaFlavor.Desktop:
23+
desc = tr('Minimal KDE Plasma installation')
24+
case _:
25+
raise ValueError(f'Unknown Plasma flavor: {self}')
26+
27+
return f'{self.value}: {desc}'
428

529

630
class PlasmaProfile(Profile):
@@ -15,18 +39,46 @@ def __init__(self) -> None:
1539
@property
1640
@override
1741
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-
]
42+
flavor_str = self.custom_settings.get(CustomSetting.PlasmaFlavor, PlasmaFlavor.Plasma.value)
43+
flavor = PlasmaFlavor(flavor_str)
44+
45+
match flavor:
46+
case PlasmaFlavor.Plasma:
47+
return [
48+
'plasma',
49+
]
50+
case PlasmaFlavor.Meta:
51+
return [
52+
'plasma-meta',
53+
]
54+
case PlasmaFlavor.Desktop:
55+
return [
56+
'plasma-desktop',
57+
]
2858

2959
@property
3060
@override
3161
def default_greeter_type(self) -> GreeterType:
3262
return GreeterType.PlasmaLoginManager
63+
64+
async def _select_flavor(self) -> None:
65+
header = tr('Select a flavor of KDE Plasma to install') + '\n'
66+
67+
items = [MenuItem(s.show(), value=s) for s in PlasmaFlavor]
68+
group = MenuItemGroup(items, sort_items=False)
69+
70+
default = self.custom_settings.get(CustomSetting.PlasmaFlavor, None)
71+
group.set_default_by_value(default)
72+
73+
result = await Selection[PlasmaFlavor](
74+
group,
75+
header=header,
76+
allow_skip=False,
77+
).show()
78+
79+
if result.type_ == ResultType.Selection:
80+
self.custom_settings[CustomSetting.PlasmaFlavor] = result.get_value().value
81+
82+
@override
83+
async def do_on_select(self) -> None:
84+
await self._select_flavor()

archinstall/default_profiles/desktops/sway.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import override
22

33
from archinstall.default_profiles.desktops import SeatAccess
4-
from archinstall.default_profiles.profile import DisplayServerType, GreeterType, Profile, ProfileType
4+
from archinstall.default_profiles.profile import CustomSetting, DisplayServerType, GreeterType, Profile, ProfileType
55
from archinstall.lib.menu.helpers import Selection
66
from archinstall.lib.translationhandler import tr
77
from archinstall.tui.ui.menu_item import MenuItem, MenuItemGroup
@@ -17,13 +17,13 @@ def __init__(self) -> None:
1717
display_server=DisplayServerType.Wayland,
1818
)
1919

20-
self.custom_settings = {'seat_access': None}
20+
self.custom_settings = {CustomSetting.SeatAccess: None}
2121

2222
@property
2323
@override
2424
def packages(self) -> list[str]:
2525
additional = []
26-
if seat := self.custom_settings.get('seat_access', None):
26+
if seat := self.custom_settings.get(CustomSetting.SeatAccess, None):
2727
additional = [seat]
2828

2929
return [
@@ -49,7 +49,7 @@ def default_greeter_type(self) -> GreeterType:
4949
@property
5050
@override
5151
def services(self) -> list[str]:
52-
if pref := self.custom_settings.get('seat_access', None):
52+
if pref := self.custom_settings.get(CustomSetting.SeatAccess, None):
5353
return [pref]
5454
return []
5555

@@ -61,7 +61,7 @@ async def _select_seat_access(self) -> None:
6161
items = [MenuItem(s.value, value=s) for s in SeatAccess]
6262
group = MenuItemGroup(items, sort_items=True)
6363

64-
default = self.custom_settings.get('seat_access', None)
64+
default = self.custom_settings.get(CustomSetting.SeatAccess, None)
6565
group.set_default_by_value(default)
6666

6767
result = await Selection[SeatAccess](
@@ -71,7 +71,7 @@ async def _select_seat_access(self) -> None:
7171
).show()
7272

7373
if result.type_ == ResultType.Selection:
74-
self.custom_settings['seat_access'] = result.get_value().value
74+
self.custom_settings[CustomSetting.SeatAccess] = result.get_value().value
7575

7676
@override
7777
async def do_on_select(self) -> None:

archinstall/default_profiles/profile.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from enum import Enum, auto
3+
from enum import Enum, StrEnum, auto
44
from typing import TYPE_CHECKING, Self
55

66
from archinstall.lib.translationhandler import tr
@@ -47,6 +47,11 @@ class SelectResult(Enum):
4747
ResetCurrent = auto()
4848

4949

50+
class CustomSetting(StrEnum):
51+
SeatAccess = 'seat_access'
52+
PlasmaFlavor = 'plasma_flavor'
53+
54+
5055
class Profile:
5156
def __init__(
5257
self,
@@ -61,7 +66,7 @@ def __init__(
6166
) -> None:
6267
self.name = name
6368
self.profile_type = profile_type
64-
self.custom_settings: dict[str, str | None] = {}
69+
self.custom_settings: dict[CustomSetting, str | None] = {}
6570

6671
self._support_gfx_driver = support_gfx_driver
6772
self._support_greeter = support_greeter
@@ -130,7 +135,7 @@ async def do_on_select(self) -> SelectResult | None:
130135
"""
131136
return SelectResult.NewSelection
132137

133-
def set_custom_settings(self, settings: dict[str, str | None]) -> None:
138+
def set_custom_settings(self, settings: dict[CustomSetting, str | None]) -> None:
134139
"""
135140
Set the custom settings for the profile.
136141
This is also called when the settings are parsed from the config

0 commit comments

Comments
 (0)