Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions archinstall/default_profiles/desktops/hyprland.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import override

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

self.custom_settings = {'seat_access': None}
self.custom_settings = {CustomSetting.SeatAccess: None}

@property
@override
Expand Down Expand Up @@ -45,7 +45,7 @@ def default_greeter_type(self) -> GreeterType:
@property
@override
def services(self) -> list[str]:
if pref := self.custom_settings.get('seat_access', None):
if pref := self.custom_settings.get(CustomSetting.SeatAccess, None):
return [pref]
return []

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

default = self.custom_settings.get('seat_access', None)
default = self.custom_settings.get(CustomSetting.SeatAccess, None)
group.set_default_by_value(default)

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

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

@override
async def do_on_select(self) -> None:
Expand Down
12 changes: 6 additions & 6 deletions archinstall/default_profiles/desktops/labwc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import override

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

self.custom_settings = {'seat_access': None}
self.custom_settings = {CustomSetting.SeatAccess: None}

@property
@override
def packages(self) -> list[str]:
additional = []
if seat := self.custom_settings.get('seat_access', None):
if seat := self.custom_settings.get(CustomSetting.SeatAccess, None):
additional = [seat]

return [
Expand All @@ -39,7 +39,7 @@ def default_greeter_type(self) -> GreeterType:
@property
@override
def services(self) -> list[str]:
if pref := self.custom_settings.get('seat_access', None):
if pref := self.custom_settings.get(CustomSetting.SeatAccess, None):
return [pref]
return []

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

default = self.custom_settings.get('seat_access', None)
default = self.custom_settings.get(CustomSetting.SeatAccess, None)
group.set_default_by_value(default)

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

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

@override
async def do_on_select(self) -> None:
Expand Down
12 changes: 6 additions & 6 deletions archinstall/default_profiles/desktops/niri.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import override

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

self.custom_settings = {'seat_access': None}
self.custom_settings = {CustomSetting.SeatAccess: None}

@property
@override
def packages(self) -> list[str]:
additional = []
if seat := self.custom_settings.get('seat_access', None):
if seat := self.custom_settings.get(CustomSetting.SeatAccess, None):
additional = [seat]

return [
Expand All @@ -47,7 +47,7 @@ def default_greeter_type(self) -> GreeterType:
@property
@override
def services(self) -> list[str]:
if pref := self.custom_settings.get('seat_access', None):
if pref := self.custom_settings.get(CustomSetting.SeatAccess, None):
return [pref]
return []

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

default = self.custom_settings.get('seat_access', None)
default = self.custom_settings.get(CustomSetting.SeatAccess, None)
group.set_default_by_value(default)

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

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

@override
async def do_on_select(self) -> None:
Expand Down
110 changes: 99 additions & 11 deletions archinstall/default_profiles/desktops/plasma.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,67 @@
from enum import StrEnum
from typing import override

from archinstall.default_profiles.profile import DisplayServerType, GreeterType, Profile, ProfileType
from archinstall.default_profiles.profile import CustomSetting, DisplayServerType, GreeterType, Profile, ProfileType
from archinstall.lib.menu.helpers import Selection
from archinstall.lib.packages.packages import available_package, package_group_info
from archinstall.lib.translationhandler import tr
from archinstall.tui.ui.menu_item import MenuItem, MenuItemGroup
from archinstall.tui.ui.result import ResultType


class PlasmaFlavor(StrEnum):
Meta = 'plasma-meta'
Plasma = 'plasma'
Desktop = 'plasma-desktop'

def show(self) -> str:
match self:
case PlasmaFlavor.Meta:
return f'{self.value} ({tr("Recommended")})'
case PlasmaFlavor.Plasma | PlasmaFlavor.Desktop:
return self.value

def package_details(self) -> str:
ty = ''
details = ''
desc = ''

match self:
case PlasmaFlavor.Meta:
ty = tr('Package')
desc = tr('Curated selection of KDE Plasma packages')
info = available_package(self.value)

if info is not None:
details = tr('Dependencies') + '\n'
details += '\n'.join(f'- {entry}' for entry in info.get_depends_on)
case PlasmaFlavor.Plasma:
ty = tr('Package group')
desc = tr('Extensive KDE Plasma installation')
group = package_group_info(self.value)

if group is not None:
details = tr('Packages in group') + '\n'
details += '\n'.join(f'- {entry}' for entry in group.packages)
case PlasmaFlavor.Desktop:
ty = tr('Package group')
desc = tr('Minimal KDE Plasma installation')
info = available_package(self.value)

if info is not None:
details = tr('Dependencies') + '\n'
details += '\n'.join(f'- {entry}' for entry in info.get_depends_on)

return f'{tr("Type")}: {ty}\n{tr("Description")}: {desc}\n\n{details}'

def packages(self) -> list[str]:
match self:
case PlasmaFlavor.Meta:
return ['plasma-meta']
case PlasmaFlavor.Plasma:
return ['plasma']
case PlasmaFlavor.Desktop:
return ['plasma-desktop']


class PlasmaProfile(Profile):
Expand All @@ -15,18 +76,45 @@ def __init__(self) -> None:
@property
@override
def packages(self) -> list[str]:
return [
'plasma-desktop',
'kscreen',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should still be kept for the minimal version i think

'plasma-pa',
'konsole',
'kate',
'dolphin',
'ark',
'plasma-workspace',
]
flavor_str = self.custom_settings.get(CustomSetting.PlasmaFlavor)

if flavor_str is not None:
flavor = PlasmaFlavor(flavor_str)
return flavor.packages()
else:
return PlasmaFlavor.Meta.packages() # use plasma-meta as the recommended default

@property
@override
def default_greeter_type(self) -> GreeterType:
return GreeterType.PlasmaLoginManager

async def _select_flavor(self) -> None:
header = tr('Select a flavor of KDE Plasma to install') + '\n'

items = [
MenuItem(
s.show(),
value=s,
preview_action=lambda x: x.value.package_details() if x.value else None,
)
for s in PlasmaFlavor
]
group = MenuItemGroup(items, sort_items=False)

default = self.custom_settings.get(CustomSetting.PlasmaFlavor, None)
group.set_default_by_value(default)

result = await Selection[PlasmaFlavor](
group,
header=header,
allow_skip=False,
preview_location='right',
).show()

if result.type_ == ResultType.Selection:
self.custom_settings[CustomSetting.PlasmaFlavor] = result.get_value().value

@override
async def do_on_select(self) -> None:
await self._select_flavor()
12 changes: 6 additions & 6 deletions archinstall/default_profiles/desktops/sway.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import override

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

self.custom_settings = {'seat_access': None}
self.custom_settings = {CustomSetting.SeatAccess: None}

@property
@override
def packages(self) -> list[str]:
additional = []
if seat := self.custom_settings.get('seat_access', None):
if seat := self.custom_settings.get(CustomSetting.SeatAccess, None):
additional = [seat]

return [
Expand All @@ -49,7 +49,7 @@ def default_greeter_type(self) -> GreeterType:
@property
@override
def services(self) -> list[str]:
if pref := self.custom_settings.get('seat_access', None):
if pref := self.custom_settings.get(CustomSetting.SeatAccess, None):
return [pref]
return []

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

default = self.custom_settings.get('seat_access', None)
default = self.custom_settings.get(CustomSetting.SeatAccess, None)
group.set_default_by_value(default)

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

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

@override
async def do_on_select(self) -> None:
Expand Down
11 changes: 8 additions & 3 deletions archinstall/default_profiles/profile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enum import Enum, auto
from enum import Enum, StrEnum, auto
from typing import TYPE_CHECKING, Self

from archinstall.lib.translationhandler import tr
Expand Down Expand Up @@ -45,6 +45,11 @@ class SelectResult(Enum):
ResetCurrent = auto()


class CustomSetting(StrEnum):
SeatAccess = 'seat_access'
PlasmaFlavor = 'plasma_flavor'


class Profile:
def __init__(
self,
Expand All @@ -59,7 +64,7 @@ def __init__(
) -> None:
self.name = name
self.profile_type = profile_type
self.custom_settings: dict[str, str | None] = {}
self.custom_settings: dict[CustomSetting, str | None] = {}

self._support_gfx_driver = support_gfx_driver
self._support_greeter = support_greeter
Expand Down Expand Up @@ -128,7 +133,7 @@ async def do_on_select(self) -> SelectResult | None:
"""
return SelectResult.NewSelection

def set_custom_settings(self, settings: dict[str, str | None]) -> None:
def set_custom_settings(self, settings: dict[CustomSetting, str | None]) -> None:
"""
Set the custom settings for the profile.
This is also called when the settings are parsed from the config
Expand Down
14 changes: 14 additions & 0 deletions archinstall/lib/models/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,26 @@ def info(self) -> str:

return output

@cached_property
def get_depends_on(self) -> list[str]:
return [entry.strip() for entry in self.depends_on.split(' ') if entry.strip()]

@cached_property
def get_optional_deps(self) -> list[str]:
return [entry.strip() for entry in self.optional_deps.split(' ') if entry.strip()]


@dataclass
class PackageGroup:
name: str
packages: list[str] = field(default_factory=list)

@classmethod
def from_package_group_output(cls, data: list[str]) -> Self:
name = data[0].split()[0].strip()
packages = [line.split()[1].strip() for line in data if line.strip()]
return cls(name, packages)

@classmethod
def from_available_packages(
cls,
Expand Down
Loading
Loading