Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Girtler <blackrabbit256@gmail.com>2023-05-06 16:09:58 +1000
committerGitHub <noreply@github.com>2023-05-06 08:09:58 +0200
commit235c1190b003b8f69ff344d6e2ac31f4bd1d0ba2 (patch)
treead9919b7452d501d3d4e8e0a94c8af92789c0f3f
parentf0fc6a77f21aabacc1c9ef772875f8dd97344af8 (diff)
Fix 1763 (#1790)
* Fix 1763 --------- Co-authored-by: Daniel Girtler <girtler.daniel@gmail.com>
-rw-r--r--archinstall/default_profiles/desktops/sway.py37
-rw-r--r--archinstall/default_profiles/profile.py25
-rw-r--r--archinstall/lib/profile/profiles_handler.py8
3 files changed, 44 insertions, 26 deletions
diff --git a/archinstall/default_profiles/desktops/sway.py b/archinstall/default_profiles/desktops/sway.py
index 519f5bbb..ae814e46 100644
--- a/archinstall/default_profiles/desktops/sway.py
+++ b/archinstall/default_profiles/desktops/sway.py
@@ -1,3 +1,4 @@
+from enum import Enum
from typing import List, Optional, TYPE_CHECKING, Any
from archinstall.default_profiles.profile import ProfileType, GreeterType
@@ -9,6 +10,11 @@ if TYPE_CHECKING:
_: Any
+class SeatAccess(Enum):
+ seatd = 'seatd'
+ polkit = 'polkit'
+
+
class SwayProfile(XorgProfile):
def __init__(self):
super().__init__(
@@ -16,10 +22,15 @@ class SwayProfile(XorgProfile):
ProfileType.WindowMgr,
description=''
)
- self._control_preference = []
+
+ self.custom_settings = {'seat_access': None}
@property
def packages(self) -> List[str]:
+ additional = []
+ if seat := self.custom_settings.get('seat_access', None):
+ additional = [seat]
+
return [
"sway",
"swaybg",
@@ -33,7 +44,7 @@ class SwayProfile(XorgProfile):
"pavucontrol",
"foot",
"xorg-xwayland"
- ] + self._control_preference
+ ] + additional
@property
def default_greeter_type(self) -> Optional[GreeterType]:
@@ -41,22 +52,26 @@ class SwayProfile(XorgProfile):
@property
def services(self) -> List[str]:
- if "seatd" in self._control_preference:
- return ['seatd']
- elif "polkit" in self._control_preference:
- return ['polkit']
-
+ if pref := self.custom_settings.get('seat_access', None):
+ return [pref.value]
return []
- def _get_system_privelege_control_preference(self):
+ def _ask_seat_access(self):
# need to activate seat service and add to seat group
title = str(_('Sway needs access to your seat (collection of hardware devices i.e. keyboard, mouse, etc)'))
title += str(_('\n\nChoose an option to give Sway access to your hardware'))
- choice = Menu(title, ["polkit", "seatd"], skip=False).run()
- self._control_preference = [choice.value]
+
+ options = [e.value for e in SeatAccess]
+ default = None
+
+ if seat := self.custom_settings.get('seat_access', None):
+ default = seat
+
+ choice = Menu(title, options, skip=False, preset_values=default).run()
+ self.custom_settings['seat_access'] = choice.single_value
def do_on_select(self):
- self._get_system_privelege_control_preference()
+ self._ask_seat_access()
def preview_text(self) -> Optional[str]:
text = str(_('Environment type: {}')).format(self.profile_type.value)
diff --git a/archinstall/default_profiles/profile.py b/archinstall/default_profiles/profile.py
index c7d6b3dc..b1ad1f50 100644
--- a/archinstall/default_profiles/profile.py
+++ b/archinstall/default_profiles/profile.py
@@ -1,6 +1,5 @@
from __future__ import annotations
-from dataclasses import dataclass
from enum import Enum, auto
from typing import List, Optional, Any, Dict, TYPE_CHECKING, TypeVar
@@ -43,20 +42,6 @@ class SelectResult(Enum):
ResetCurrent = auto()
-@dataclass
-class ProfileInfo:
- name: str
- details: Optional[str]
- gfx_driver: Optional[str] = None
- greeter: Optional[str] = None
-
- @property
- def absolute_name(self) -> str:
- if self.details is not None:
- return self.details
- return self.name
-
-
class Profile:
def __init__(
self,
@@ -72,6 +57,8 @@ class Profile:
self.name = name
self.description = description
self.profile_type = profile_type
+ self.custom_settings: Dict[str, Any] = {}
+
self._support_gfx_driver = support_gfx_driver
self._support_greeter = support_greeter
@@ -135,6 +122,14 @@ class Profile:
"""
return SelectResult.NewSelection
+ def set_custom_settings(self, settings: Dict[str, Any]):
+ """
+ Set the custom settings for the profile.
+ This is also called when the settings are parsed from the config
+ and can be overriden to perform further actions based on the profile
+ """
+ self.custom_settings = settings
+
def current_selection_names(self) -> List[str]:
if self._current_selection:
return [s.name for s in self._current_selection]
diff --git a/archinstall/lib/profile/profiles_handler.py b/archinstall/lib/profile/profiles_handler.py
index 824849c3..6ed95f8e 100644
--- a/archinstall/lib/profile/profiles_handler.py
+++ b/archinstall/lib/profile/profiles_handler.py
@@ -43,6 +43,7 @@ class ProfileHandler:
data = {
'main': profile.name,
'details': [profile.name for profile in profile.current_selection],
+ 'custom_settings': {profile.name: profile.custom_settings for profile in profile.current_selection}
}
if self._url_path is not None:
@@ -98,6 +99,7 @@ class ProfileHandler:
profile = self.get_profile_by_name(main) if main else None
valid: List[Profile] = []
+
if details := profile_config.get('details', []):
resolved = {detail: self.get_profile_by_name(detail) for detail in details if detail}
valid = [p for p in resolved.values() if p is not None]
@@ -106,6 +108,12 @@ class ProfileHandler:
if invalid:
log(f'No profile definition found: {invalid}')
+ custom_settings = profile_config.get('custom_settings', {})
+ for profile in valid:
+ profile.set_custom_settings(
+ custom_settings.get(profile.name, {})
+ )
+
if profile is not None:
profile.set_current_selection(valid)