Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall/lib')
-rw-r--r--archinstall/lib/global_menu.py27
-rw-r--r--archinstall/lib/interactions/general_conf.py30
-rw-r--r--archinstall/lib/models/__init__.py1
-rw-r--r--archinstall/lib/models/audio_configuration.py54
4 files changed, 94 insertions, 18 deletions
diff --git a/archinstall/lib/global_menu.py b/archinstall/lib/global_menu.py
index 5503d9ce..fb62b7b5 100644
--- a/archinstall/lib/global_menu.py
+++ b/archinstall/lib/global_menu.py
@@ -1,6 +1,6 @@
from __future__ import annotations
-from typing import Any, List, Optional, Union, Dict, TYPE_CHECKING
+from typing import Any, List, Optional, Dict, TYPE_CHECKING
from . import disk
from .general import secret
@@ -9,6 +9,7 @@ from .menu import Selector, AbstractMenu
from .mirrors import MirrorConfiguration, MirrorMenu
from .models import NetworkConfiguration, NicType
from .models.bootloader import Bootloader
+from .models.audio_configuration import Audio, AudioConfiguration
from .models.users import User
from .output import FormattedOutput
from .profile.profile_menu import ProfileConfiguration
@@ -109,12 +110,11 @@ class GlobalMenu(AbstractMenu):
display_func=lambda x: x.profile.name if x else '',
preview_func=self._prev_profile
)
- self._menu_options['audio'] = \
+ self._menu_options['audio_config'] = \
Selector(
_('Audio'),
lambda preset: self._select_audio(preset),
- display_func=lambda x: x if x else '',
- default=None
+ display_func=lambda x: self._display_audio(x)
)
self._menu_options['parallel downloads'] = \
Selector(
@@ -421,13 +421,18 @@ class GlobalMenu(AbstractMenu):
profile_config = ProfileMenu(store, preset=current_profile).run()
return profile_config
- def _select_audio(self, current: Union[str, None]) -> Optional[str]:
- profile_config: Optional[ProfileConfiguration] = self._menu_options['profile_config'].current_selection
- if profile_config and profile_config.profile:
- is_desktop = profile_config.profile.is_desktop_profile() if profile_config else False
- selection = ask_for_audio_selection(is_desktop, current)
- return selection
- return None
+ def _select_audio(
+ self,
+ current: Optional[AudioConfiguration] = None
+ ) -> Optional[AudioConfiguration]:
+ selection = ask_for_audio_selection(current)
+ return selection
+
+ def _display_audio(self, current: Optional[AudioConfiguration]) -> str:
+ if not current:
+ return Audio.no_audio_text()
+ else:
+ return current.audio.name
def _create_user_account(self, defined_users: List[User]) -> List[User]:
users = ask_for_additional_users(defined_users=defined_users)
diff --git a/archinstall/lib/interactions/general_conf.py b/archinstall/lib/interactions/general_conf.py
index ad9ee386..1c570a69 100644
--- a/archinstall/lib/interactions/general_conf.py
+++ b/archinstall/lib/interactions/general_conf.py
@@ -5,6 +5,7 @@ from typing import List, Any, Optional, TYPE_CHECKING
from ..locale import list_timezones, list_keyboard_languages
from ..menu import MenuSelectionType, Menu, TextInput
+from ..models.audio_configuration import Audio, AudioConfiguration
from ..output import warn
from ..packages.packages import validate_package_list
from ..storage import storage
@@ -55,16 +56,31 @@ def ask_for_a_timezone(preset: Optional[str] = None) -> Optional[str]:
return None
-def ask_for_audio_selection(desktop: bool = True, preset: Optional[str] = None) -> Optional[str]:
- no_audio = str(_('No audio server'))
- choices = ['pipewire', 'pulseaudio'] if desktop else ['pipewire', 'pulseaudio', no_audio]
- default = 'pipewire' if desktop else no_audio
+def ask_for_audio_selection(
+ current: Optional[AudioConfiguration] = None
+) -> Optional[AudioConfiguration]:
+ choices = [
+ Audio.Pipewire.name,
+ Audio.Pulseaudio.name,
+ Audio.no_audio_text()
+ ]
- choice = Menu(_('Choose an audio server'), choices, preset_values=preset, default_option=default).run()
+ preset = current.audio.name if current else None
+
+ choice = Menu(
+ _('Choose an audio server'),
+ choices,
+ preset_values=preset
+ ).run()
match choice.type_:
- case MenuSelectionType.Skip: return preset
- case MenuSelectionType.Selection: return choice.single_value
+ case MenuSelectionType.Skip: return current
+ case MenuSelectionType.Selection:
+ value = choice.single_value
+ if value == Audio.no_audio_text():
+ return None
+ else:
+ return AudioConfiguration(Audio[value])
return None
diff --git a/archinstall/lib/models/__init__.py b/archinstall/lib/models/__init__.py
index 7415f63f..a1c90e48 100644
--- a/archinstall/lib/models/__init__.py
+++ b/archinstall/lib/models/__init__.py
@@ -6,3 +6,4 @@ from .network_configuration import (
from .bootloader import Bootloader
from .gen import VersionDef, PackageSearchResult, PackageSearch, LocalPackage
from .users import PasswordStrength, User
+from .audio_configuration import Audio, AudioConfiguration
diff --git a/archinstall/lib/models/audio_configuration.py b/archinstall/lib/models/audio_configuration.py
new file mode 100644
index 00000000..3a4029db
--- /dev/null
+++ b/archinstall/lib/models/audio_configuration.py
@@ -0,0 +1,54 @@
+from dataclasses import dataclass
+from enum import Enum
+from typing import Any, TYPE_CHECKING, Dict
+
+from ..hardware import SysInfo
+from ..output import info
+from ...default_profiles.applications.pipewire import PipewireProfile
+
+if TYPE_CHECKING:
+ _: Any
+
+
+@dataclass
+class Audio(Enum):
+ Pipewire = 'pipewire'
+ Pulseaudio = 'pulseaudio'
+
+ @staticmethod
+ def no_audio_text() -> str:
+ return str(_('No audio server'))
+
+
+@dataclass
+class AudioConfiguration:
+ audio: Audio
+
+ def __dump__(self) -> Dict[str, Any]:
+ return {
+ 'audio': self.audio.value
+ }
+
+ @staticmethod
+ def parse_arg(arg: Dict[str, Any]) -> 'AudioConfiguration':
+ return AudioConfiguration(
+ Audio(arg['audio'])
+ )
+
+ def install_audio_config(
+ self,
+ installation: Any
+ ):
+ info(f'Installing audio server: {self.audio.name}')
+
+ match self.audio:
+ case Audio.Pipewire:
+ PipewireProfile().install(installation)
+ case Audio.Pulseaudio:
+ installation.add_additional_packages("pulseaudio")
+
+ if SysInfo.requires_sof_fw():
+ installation.add_additional_packages('sof-firmware')
+
+ if SysInfo.requires_alsa_fw():
+ installation.add_additional_packages('alsa-firmware')