You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.3 KiB
41 lines
1.3 KiB
from calculate.variables.datavars import Variable, Namespace, Dependence, \
|
|
StringType, BooleanType, HashType, ListType, Calculate, Copy
|
|
from calculate.vars.main.os.func import get_arch_gentoo
|
|
|
|
from calculate.utils.package import PackageAtomParser
|
|
|
|
def get_available_audio_system():
|
|
audio_systems = (
|
|
('alsa', None),
|
|
('pulseaudio', 'media-sound/pulseaudio')
|
|
)
|
|
package_db = PackageAtomParser()
|
|
return [
|
|
audio_system
|
|
for audio_system, pkg in audio_systems
|
|
if pkg is None or package_db.is_package_exists(pkg)
|
|
]
|
|
|
|
def get_audio_selected(available_systems, cmdline_audio):
|
|
available_systems = available_systems.value
|
|
|
|
if 'pulseaudio' in available_systems:
|
|
cmdline_audio = cmdline_audio.value
|
|
if cmdline_audio and cmdline_audio == 'alsa':
|
|
return 'alsa'
|
|
else:
|
|
return 'pulseaudio'
|
|
return 'alsa'
|
|
|
|
with Namespace("arch"):
|
|
Variable("machine", type=StringType,
|
|
source=Copy("main.os.arch.machine"))
|
|
Variable("gentoo", type=StringType,
|
|
source=Calculate(get_arch_gentoo, ".machine"))
|
|
|
|
with Namespace("audio"):
|
|
Variable("available", type=ListType,
|
|
source=Calculate(get_available_audio_system))
|
|
Variable("selected", type=StringType,
|
|
source=Calculate(get_audio_selected, ".available", "main.cl.cmdline.calculate.audio"))
|