Refactor profile seat access selection (#4457)
* Refactor profile seat access selection * Update
This commit is contained in:
parent
b5501d9507
commit
ba7dbeadfc
|
|
@ -1,6 +0,0 @@
|
|||
from enum import Enum
|
||||
|
||||
|
||||
class SeatAccess(Enum):
|
||||
seatd = 'seatd'
|
||||
polkit = 'polkit'
|
||||
|
|
@ -1,11 +1,7 @@
|
|||
from typing import override
|
||||
|
||||
from archinstall.default_profiles.desktops import SeatAccess
|
||||
from archinstall.default_profiles.desktops.utils import select_seat_access
|
||||
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.menu_item import MenuItem, MenuItemGroup
|
||||
from archinstall.tui.result import ResultType
|
||||
|
||||
|
||||
class HyprlandProfile(Profile):
|
||||
|
|
@ -49,26 +45,8 @@ class HyprlandProfile(Profile):
|
|||
return [pref]
|
||||
return []
|
||||
|
||||
async def _select_seat_access(self) -> None:
|
||||
# need to activate seat service and add to seat group
|
||||
header = tr('Hyprland needs access to your seat (collection of hardware devices i.e. keyboard, mouse, etc)')
|
||||
header += '\n' + tr('Choose an option to give Hyprland access to your hardware') + '\n'
|
||||
|
||||
items = [MenuItem(s.value, value=s) for s in SeatAccess]
|
||||
group = MenuItemGroup(items, sort_items=True)
|
||||
|
||||
default = self.custom_settings.get(CustomSetting.SeatAccess, None)
|
||||
group.set_default_by_value(default)
|
||||
|
||||
result = await Selection[SeatAccess](
|
||||
group,
|
||||
header=header,
|
||||
allow_skip=False,
|
||||
).show()
|
||||
|
||||
if result.type_ == ResultType.Selection:
|
||||
self.custom_settings[CustomSetting.SeatAccess] = result.get_value().value
|
||||
|
||||
@override
|
||||
async def do_on_select(self) -> None:
|
||||
await self._select_seat_access()
|
||||
default = self.custom_settings.get(CustomSetting.SeatAccess, None)
|
||||
seat_access = await select_seat_access(self.name, default)
|
||||
self.custom_settings[CustomSetting.SeatAccess] = seat_access.value
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
from typing import override
|
||||
|
||||
from archinstall.default_profiles.desktops import SeatAccess
|
||||
from archinstall.default_profiles.desktops.utils import select_seat_access
|
||||
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.menu_item import MenuItem, MenuItemGroup
|
||||
from archinstall.tui.result import ResultType
|
||||
|
||||
|
||||
class LabwcProfile(Profile):
|
||||
|
|
@ -43,26 +39,8 @@ class LabwcProfile(Profile):
|
|||
return [pref]
|
||||
return []
|
||||
|
||||
async def _select_seat_access(self) -> None:
|
||||
# need to activate seat service and add to seat group
|
||||
header = tr('labwc needs access to your seat (collection of hardware devices i.e. keyboard, mouse, etc)')
|
||||
header += '\n' + tr('Choose an option to give labwc access to your hardware') + '\n'
|
||||
|
||||
items = [MenuItem(s.value, value=s) for s in SeatAccess]
|
||||
group = MenuItemGroup(items, sort_items=True)
|
||||
|
||||
default = self.custom_settings.get(CustomSetting.SeatAccess, None)
|
||||
group.set_default_by_value(default)
|
||||
|
||||
result = await Selection[SeatAccess](
|
||||
group,
|
||||
header=header,
|
||||
allow_skip=False,
|
||||
).show()
|
||||
|
||||
if result.type_ == ResultType.Selection:
|
||||
self.custom_settings[CustomSetting.SeatAccess] = result.get_value().value
|
||||
|
||||
@override
|
||||
async def do_on_select(self) -> None:
|
||||
await self._select_seat_access()
|
||||
default = self.custom_settings.get(CustomSetting.SeatAccess, None)
|
||||
seat_access = await select_seat_access(self.name, default)
|
||||
self.custom_settings[CustomSetting.SeatAccess] = seat_access.value
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
from typing import override
|
||||
|
||||
from archinstall.default_profiles.desktops import SeatAccess
|
||||
from archinstall.default_profiles.desktops.utils import select_seat_access
|
||||
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.menu_item import MenuItem, MenuItemGroup
|
||||
from archinstall.tui.result import ResultType
|
||||
|
||||
|
||||
class NiriProfile(Profile):
|
||||
|
|
@ -51,26 +47,8 @@ class NiriProfile(Profile):
|
|||
return [pref]
|
||||
return []
|
||||
|
||||
async def _select_seat_access(self) -> None:
|
||||
# need to activate seat service and add to seat group
|
||||
header = tr('niri needs access to your seat (collection of hardware devices i.e. keyboard, mouse, etc)')
|
||||
header += '\n' + tr('Choose an option to give niri access to your hardware') + '\n'
|
||||
|
||||
items = [MenuItem(s.value, value=s) for s in SeatAccess]
|
||||
group = MenuItemGroup(items, sort_items=True)
|
||||
|
||||
default = self.custom_settings.get(CustomSetting.SeatAccess, None)
|
||||
group.set_default_by_value(default)
|
||||
|
||||
result = await Selection[SeatAccess](
|
||||
group,
|
||||
header=header,
|
||||
allow_skip=False,
|
||||
).show()
|
||||
|
||||
if result.type_ == ResultType.Selection:
|
||||
self.custom_settings[CustomSetting.SeatAccess] = result.get_value().value
|
||||
|
||||
@override
|
||||
async def do_on_select(self) -> None:
|
||||
await self._select_seat_access()
|
||||
default = self.custom_settings.get(CustomSetting.SeatAccess, None)
|
||||
seat_access = await select_seat_access(self.name, default)
|
||||
self.custom_settings[CustomSetting.SeatAccess] = seat_access.value
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
from typing import override
|
||||
|
||||
from archinstall.default_profiles.desktops import SeatAccess
|
||||
from archinstall.default_profiles.desktops.utils import select_seat_access
|
||||
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.menu_item import MenuItem, MenuItemGroup
|
||||
from archinstall.tui.result import ResultType
|
||||
|
||||
|
||||
class SwayProfile(Profile):
|
||||
|
|
@ -53,26 +49,8 @@ class SwayProfile(Profile):
|
|||
return [pref]
|
||||
return []
|
||||
|
||||
async def _select_seat_access(self) -> None:
|
||||
# need to activate seat service and add to seat group
|
||||
header = tr('Sway needs access to your seat (collection of hardware devices i.e. keyboard, mouse, etc)')
|
||||
header += '\n' + tr('Choose an option to give Sway access to your hardware') + '\n'
|
||||
|
||||
items = [MenuItem(s.value, value=s) for s in SeatAccess]
|
||||
group = MenuItemGroup(items, sort_items=True)
|
||||
|
||||
default = self.custom_settings.get(CustomSetting.SeatAccess, None)
|
||||
group.set_default_by_value(default)
|
||||
|
||||
result = await Selection[SeatAccess](
|
||||
group,
|
||||
header=header,
|
||||
allow_skip=False,
|
||||
).show()
|
||||
|
||||
if result.type_ == ResultType.Selection:
|
||||
self.custom_settings[CustomSetting.SeatAccess] = result.get_value().value
|
||||
|
||||
@override
|
||||
async def do_on_select(self) -> None:
|
||||
await self._select_seat_access()
|
||||
default = self.custom_settings.get(CustomSetting.SeatAccess, None)
|
||||
seat_access = await select_seat_access(self.name, default)
|
||||
self.custom_settings[CustomSetting.SeatAccess] = seat_access.value
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
from enum import Enum
|
||||
|
||||
from archinstall.lib.menu.helpers import Selection
|
||||
from archinstall.lib.translationhandler import tr
|
||||
from archinstall.tui.menu_item import MenuItem, MenuItemGroup
|
||||
from archinstall.tui.result import ResultType
|
||||
|
||||
|
||||
class SeatAccess(Enum):
|
||||
seatd = 'seatd'
|
||||
polkit = 'polkit'
|
||||
|
||||
|
||||
async def select_seat_access(profile_name: str, default: str | None) -> SeatAccess:
|
||||
header = tr('{} needs access to your seat').format(profile_name)
|
||||
header += f' ({tr("collection of hardware devices i.e. keyboard, mouse")})' + '\n'
|
||||
header += tr('Choose an option how to give {} access to your hardware').format(profile_name)
|
||||
|
||||
items = [MenuItem(s.value, value=s) for s in SeatAccess]
|
||||
group = MenuItemGroup(items, sort_items=True)
|
||||
|
||||
group.set_default_by_value(default)
|
||||
|
||||
result = await Selection[SeatAccess](
|
||||
group,
|
||||
header=header,
|
||||
allow_skip=False,
|
||||
).show()
|
||||
|
||||
if result.type_ == ResultType.Selection:
|
||||
return result.get_value()
|
||||
else:
|
||||
raise ValueError('Unexpected result type from seat access selection')
|
||||
Loading…
Reference in New Issue