Fix 1763 (#1790)
* Fix 1763 --------- Co-authored-by: Daniel Girtler <girtler.daniel@gmail.com>
This commit is contained in:
parent
f0fc6a77f2
commit
235c1190b0
|
|
@ -1,3 +1,4 @@
|
||||||
|
from enum import Enum
|
||||||
from typing import List, Optional, TYPE_CHECKING, Any
|
from typing import List, Optional, TYPE_CHECKING, Any
|
||||||
|
|
||||||
from archinstall.default_profiles.profile import ProfileType, GreeterType
|
from archinstall.default_profiles.profile import ProfileType, GreeterType
|
||||||
|
|
@ -9,6 +10,11 @@ if TYPE_CHECKING:
|
||||||
_: Any
|
_: Any
|
||||||
|
|
||||||
|
|
||||||
|
class SeatAccess(Enum):
|
||||||
|
seatd = 'seatd'
|
||||||
|
polkit = 'polkit'
|
||||||
|
|
||||||
|
|
||||||
class SwayProfile(XorgProfile):
|
class SwayProfile(XorgProfile):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(
|
super().__init__(
|
||||||
|
|
@ -16,10 +22,15 @@ class SwayProfile(XorgProfile):
|
||||||
ProfileType.WindowMgr,
|
ProfileType.WindowMgr,
|
||||||
description=''
|
description=''
|
||||||
)
|
)
|
||||||
self._control_preference = []
|
|
||||||
|
self.custom_settings = {'seat_access': None}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def packages(self) -> List[str]:
|
def packages(self) -> List[str]:
|
||||||
|
additional = []
|
||||||
|
if seat := self.custom_settings.get('seat_access', None):
|
||||||
|
additional = [seat]
|
||||||
|
|
||||||
return [
|
return [
|
||||||
"sway",
|
"sway",
|
||||||
"swaybg",
|
"swaybg",
|
||||||
|
|
@ -33,7 +44,7 @@ class SwayProfile(XorgProfile):
|
||||||
"pavucontrol",
|
"pavucontrol",
|
||||||
"foot",
|
"foot",
|
||||||
"xorg-xwayland"
|
"xorg-xwayland"
|
||||||
] + self._control_preference
|
] + additional
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def default_greeter_type(self) -> Optional[GreeterType]:
|
def default_greeter_type(self) -> Optional[GreeterType]:
|
||||||
|
|
@ -41,22 +52,26 @@ class SwayProfile(XorgProfile):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def services(self) -> List[str]:
|
def services(self) -> List[str]:
|
||||||
if "seatd" in self._control_preference:
|
if pref := self.custom_settings.get('seat_access', None):
|
||||||
return ['seatd']
|
return [pref.value]
|
||||||
elif "polkit" in self._control_preference:
|
|
||||||
return ['polkit']
|
|
||||||
|
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def _get_system_privelege_control_preference(self):
|
def _ask_seat_access(self):
|
||||||
# need to activate seat service and add to seat group
|
# 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(_('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'))
|
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):
|
def do_on_select(self):
|
||||||
self._get_system_privelege_control_preference()
|
self._ask_seat_access()
|
||||||
|
|
||||||
def preview_text(self) -> Optional[str]:
|
def preview_text(self) -> Optional[str]:
|
||||||
text = str(_('Environment type: {}')).format(self.profile_type.value)
|
text = str(_('Environment type: {}')).format(self.profile_type.value)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from dataclasses import dataclass
|
|
||||||
from enum import Enum, auto
|
from enum import Enum, auto
|
||||||
from typing import List, Optional, Any, Dict, TYPE_CHECKING, TypeVar
|
from typing import List, Optional, Any, Dict, TYPE_CHECKING, TypeVar
|
||||||
|
|
||||||
|
|
@ -43,20 +42,6 @@ class SelectResult(Enum):
|
||||||
ResetCurrent = auto()
|
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:
|
class Profile:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
|
@ -72,6 +57,8 @@ class Profile:
|
||||||
self.name = name
|
self.name = name
|
||||||
self.description = description
|
self.description = description
|
||||||
self.profile_type = profile_type
|
self.profile_type = profile_type
|
||||||
|
self.custom_settings: Dict[str, Any] = {}
|
||||||
|
|
||||||
self._support_gfx_driver = support_gfx_driver
|
self._support_gfx_driver = support_gfx_driver
|
||||||
self._support_greeter = support_greeter
|
self._support_greeter = support_greeter
|
||||||
|
|
||||||
|
|
@ -135,6 +122,14 @@ class Profile:
|
||||||
"""
|
"""
|
||||||
return SelectResult.NewSelection
|
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]:
|
def current_selection_names(self) -> List[str]:
|
||||||
if self._current_selection:
|
if self._current_selection:
|
||||||
return [s.name for s in self._current_selection]
|
return [s.name for s in self._current_selection]
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ class ProfileHandler:
|
||||||
data = {
|
data = {
|
||||||
'main': profile.name,
|
'main': profile.name,
|
||||||
'details': [profile.name for profile in profile.current_selection],
|
'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:
|
if self._url_path is not None:
|
||||||
|
|
@ -98,6 +99,7 @@ class ProfileHandler:
|
||||||
profile = self.get_profile_by_name(main) if main else None
|
profile = self.get_profile_by_name(main) if main else None
|
||||||
|
|
||||||
valid: List[Profile] = []
|
valid: List[Profile] = []
|
||||||
|
|
||||||
if details := profile_config.get('details', []):
|
if details := profile_config.get('details', []):
|
||||||
resolved = {detail: self.get_profile_by_name(detail) for detail in details if detail}
|
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]
|
valid = [p for p in resolved.values() if p is not None]
|
||||||
|
|
@ -106,6 +108,12 @@ class ProfileHandler:
|
||||||
if invalid:
|
if invalid:
|
||||||
log(f'No profile definition found: {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:
|
if profile is not None:
|
||||||
profile.set_current_selection(valid)
|
profile.set_current_selection(valid)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue