Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall')
-rw-r--r--archinstall/__init__.py3
-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
-rw-r--r--archinstall/scripts/guided.py19
-rw-r--r--archinstall/scripts/swiss.py19
7 files changed, 110 insertions, 43 deletions
diff --git a/archinstall/__init__.py b/archinstall/__init__.py
index c4b64912..cfaecd16 100644
--- a/archinstall/__init__.py
+++ b/archinstall/__init__.py
@@ -237,6 +237,9 @@ def load_config():
if arguments.get('bootloader', None) is not None:
arguments['bootloader'] = models.Bootloader.from_arg(arguments['bootloader'])
+ if arguments.get('audio_config', None) is not None:
+ arguments['audio_config'] = models.AudioConfiguration.parse_arg(arguments['audio_config'])
+
if arguments.get('disk_encryption', None) is not None and disk_config is not None:
password = arguments.get('encryption_password', '')
arguments['disk_encryption'] = disk.DiskEncryption.parse_arg(
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')
diff --git a/archinstall/scripts/guided.py b/archinstall/scripts/guided.py
index c8df590d..605d2b0e 100644
--- a/archinstall/scripts/guided.py
+++ b/archinstall/scripts/guided.py
@@ -8,11 +8,11 @@ from archinstall import SysInfo
from archinstall.lib import locale
from archinstall.lib import disk
from archinstall.lib.global_menu import GlobalMenu
-from archinstall.default_profiles.applications.pipewire import PipewireProfile
from archinstall.lib.configuration import ConfigurationOutput
from archinstall.lib.installer import Installer
from archinstall.lib.menu import Menu
from archinstall.lib.mirrors import use_mirrors, add_custom_mirrors
+from archinstall.lib.models import AudioConfiguration
from archinstall.lib.models.bootloader import Bootloader
from archinstall.lib.models.network_configuration import NetworkConfiguration
from archinstall.lib.networking import check_mirror_reachable
@@ -70,7 +70,7 @@ def ask_user_questions():
global_menu.enable('profile_config')
# Ask about audio server selection if one is not already set
- global_menu.enable('audio')
+ global_menu.enable('audio_config')
# Ask for preferred kernel:
global_menu.enable('kernels', mandatory=True)
@@ -172,18 +172,9 @@ def perform_installation(mountpoint: Path):
if users := archinstall.arguments.get('!users', None):
installation.create_users(users)
- if audio := archinstall.arguments.get('audio', None):
- info(f'Installing audio server: {audio}')
- if audio == 'pipewire':
- PipewireProfile().install(installation)
- elif 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')
+ audio_config: Optional[AudioConfiguration] = archinstall.arguments.get('audio_config', None)
+ if audio_config:
+ audio_config.install_audio_config(installation)
else:
info("No audio server will be installed")
diff --git a/archinstall/scripts/swiss.py b/archinstall/scripts/swiss.py
index a2ab0549..cd532f6d 100644
--- a/archinstall/scripts/swiss.py
+++ b/archinstall/scripts/swiss.py
@@ -1,7 +1,7 @@
import os
from enum import Enum
from pathlib import Path
-from typing import TYPE_CHECKING, Any, Dict
+from typing import TYPE_CHECKING, Any, Dict, Optional
import archinstall
from archinstall import SysInfo, info, debug
@@ -9,13 +9,13 @@ from archinstall.lib import mirrors
from archinstall.lib import models
from archinstall.lib import disk
from archinstall.lib import locale
+from archinstall.lib.models import AudioConfiguration
from archinstall.lib.networking import check_mirror_reachable
from archinstall.lib.profile.profiles_handler import profile_handler
from archinstall.lib import menu
from archinstall.lib.global_menu import GlobalMenu
from archinstall.lib.installer import Installer
from archinstall.lib.configuration import ConfigurationOutput
-from archinstall.default_profiles.applications.pipewire import PipewireProfile
if TYPE_CHECKING:
_: Any
@@ -95,7 +95,7 @@ class SwissMainMenu(GlobalMenu):
options_list = [
'mirror_config', 'disk_config',
'disk_encryption', 'swap', 'bootloader', 'hostname', '!root-password',
- '!users', 'profile_config', 'audio', 'kernels', 'packages', 'additional-repositories', 'network_config',
+ '!users', 'profile_config', 'audio_config', 'kernels', 'packages', 'additional-repositories', 'network_config',
'timezone', 'ntp'
]
@@ -109,7 +109,7 @@ class SwissMainMenu(GlobalMenu):
case ExecutionMode.Only_OS:
options_list = [
'mirror_config','bootloader', 'hostname',
- '!root-password', '!users', 'profile_config', 'audio', 'kernels',
+ '!root-password', '!users', 'profile_config', 'audio_config', 'kernels',
'packages', 'additional-repositories', 'network_config', 'timezone', 'ntp'
]
@@ -236,14 +236,11 @@ def perform_installation(mountpoint: Path, exec_mode: ExecutionMode):
if users := archinstall.arguments.get('!users', None):
installation.create_users(users)
- if audio := archinstall.arguments.get('audio', None):
- info(f'Installing audio server: {audio}')
- if audio == 'pipewire':
- PipewireProfile().install(installation)
- elif audio == 'pulseaudio':
- installation.add_additional_packages("pulseaudio")
+ audio_config: Optional[AudioConfiguration] = archinstall.arguments.get('audio_config', None)
+ if audio_config:
+ audio_config.install_audio_config(installation)
else:
- info("No audio server will be installed.")
+ info("No audio server will be installed")
if profile_config := archinstall.arguments.get('profile_config', None):
profile_handler.install_profile_config(installation, profile_config)