Если вы хотите, чтобы были установлены все пакеты в $ INSTALLATION_PACKAGES
, просто ] apt-get install
все из них и затем проверяют, не удалось ли выполнить какой-либо из них:
apt-get -y $INSTALLATION_PACKAGES
list=$(dpkg -l | grep ^ii)
for i in $INSTALLATION_PACKAGES do
echo "$list" | grep -w "$i" || echo "$i" >> $FAILED_INSTALL
done
Вы можете сделать это с помощью amixer
.
amixer -c 0 cset name='Analog Output Playback Enum' 0
Где 0 в -c 0
представляет номер карты. Последний параметр выглядит следующим образом:
0 - 'Stereo Headphones'
1 - 'Stereo Headphones FP'
2 - 'Multichannel'
Я считаю, что вы можете сделать это, используя ряд инструментов, таких как amixer
, или pamd
, или pactl
.
ПРИМЕЧАНИЕ.:Ваше предположение — это то, как я понимаю вещи. Sinks я приравниваю к реальным звуковым картам (output ), а выходы на них называются портами.
Фактическое определение из этого руководства под названием PulseAudio под капотом:
Sink
A sink is an output device. It is an active unit that consumes samples.
Sink usually runs a thread with its own event loop, peeks sample chunks from connected sink inputs, and mixes them. It also implements clocking and maintains latency. The rest of the world usually communicates with a sink using messages.
The typical sink represents an output sound device, e.g. headphones connected to a sound card line output or on a Bluetooth headset. PulseAudio automatically creates a sink for every detected output device.
Вот пример, показывающий, как использоватьpactl
:
$ pactl list sinks |& grep -E "Sink|Ports|analog-ou"
Sink #0
Ports:
analog-output-lineout: Line Out (priority: 9900, not available)
analog-output-headphones: Headphones (priority: 9000, not available)
Active Port: analog-output-lineout
Выше вы можете видеть, что Active Port:
в настоящее время является линейкой моей звуковой карты. Давайте изменим это на наушники.
$ pactl set-sink-port 0 analog-output-headphones
А если еще раз проверим:
$ pactl list sinks |& grep -E "Sink|Ports|analog-ou"
X11 connection rejected because of wrong authentication.
Sink #0
Ports:
analog-output-lineout: Line Out (priority: 9900, not available)
analog-output-headphones: Headphones (priority: 9000, not available)
Active Port: analog-output-headphones
Изman pactl
:
set-sink-port SINK PORT
Set the specified sink (identified by its symbolic name or
numerical index) to the specified port (identified by its symbolic
name).
В редких случаях я замечал, что устройство вывода звука таинственным образом исчезает из списка устройств. Если вы обнаружите, что это происходит, вы можете легко решить эту проблему, сказав Pulse Audio перезагрузить свои модули :
.$ pactl load-module module-detect
Я использовал pacmd
для автоматического переключения звука с динамиков ПК на HDMI:
if grep '^connected$' /sys/class/drm/card0/card0-HDMI*/status ;then
sleep 2
pacmd set-card-profile 0 output:hdmi-stereo
else
sleep 2
pacmd set-card-profile 0 output:analog-stereo+input:analog-stereo
fi
Чтобы получить активный звуковой профиль:
pacmd list |grep 'active profile'
active profile: <output:analog-stereo+input:analog-stereo>
Список всех доступных поддерживаемых профилей вывода звука:
pacmd list |grep 'output:'