diff options
author | Simon Rettberg | 2014-09-29 16:05:00 +0200 |
---|---|---|
committer | root | 2014-09-29 16:05:00 +0200 |
commit | 2dee2021d08a0837ce40941fff43a4b09d692146 (patch) | |
tree | b56c98d715604d763c458b0d3af792014c80a1ad /remote/modules | |
parent | [vmware] Support for 10.0.3 (diff) | |
download | tm-scripts-2dee2021d08a0837ce40941fff43a4b09d692146.tar.gz tm-scripts-2dee2021d08a0837ce40941fff43a4b09d692146.tar.xz tm-scripts-2dee2021d08a0837ce40941fff43a4b09d692146.zip |
[alsa] Set default sound card to first non-HDMI card
Diffstat (limited to 'remote/modules')
3 files changed, 59 insertions, 0 deletions
diff --git a/remote/modules/alsa/data/etc/systemd/system/alsa-default-card.service b/remote/modules/alsa/data/etc/systemd/system/alsa-default-card.service new file mode 100644 index 00000000..db35eeb7 --- /dev/null +++ b/remote/modules/alsa/data/etc/systemd/system/alsa-default-card.service @@ -0,0 +1,11 @@ +[Unit] +Description=Set default card ALSA will use +DefaultDependencies=no +After=tmp.target +Wants=tmp.target + +[Service] +Type=oneshot +ExecStart=/opt/openslx/scripts/alsa-default_card +RemainAfterExit=yes + diff --git a/remote/modules/alsa/data/etc/systemd/system/multi-user.target.wants/alsa-default-card.service b/remote/modules/alsa/data/etc/systemd/system/multi-user.target.wants/alsa-default-card.service new file mode 120000 index 00000000..55e393fd --- /dev/null +++ b/remote/modules/alsa/data/etc/systemd/system/multi-user.target.wants/alsa-default-card.service @@ -0,0 +1 @@ +../alsa-default-card.service
\ No newline at end of file diff --git a/remote/modules/alsa/data/opt/openslx/scripts/alsa-default_card b/remote/modules/alsa/data/opt/openslx/scripts/alsa-default_card new file mode 100755 index 00000000..4edfcdd5 --- /dev/null +++ b/remote/modules/alsa/data/opt/openslx/scripts/alsa-default_card @@ -0,0 +1,47 @@ +#!/bin/ash + +PROC="/proc/asound/cards" + +if [ ! -r "$PROC" ]; then + echo "'${PROC}' not found or not readable." + exit 1 +fi + +if [ -w "/etc" ]; then + FILE="/etc/asound.conf" +elif [ -n "$HOME" ]; then + FILE="${HOME}/.asoundrc" +else + FILE="$(getent passwd root | awk -F ':' '{print $6}')/.asoundrc" +fi + +if [ -e "${FILE}" -a "x$1" != "x--force" ]; then + echo "'${FILE}' already exists, use --force to overwrite." + exit 1 +fi + +# Try to filter HDMI cards first +CARD=$(grep -v -i 'HDMI' "${PROC}" | grep -E -o '^[[:space:]]*[0-9]+[[:space:]]+' | head -n 1) +# If empty, try again with all +[ -z "${CARD}" ] && CARD=$(cat "${PROC}" | grep -E -o '^[[:space:]]*[0-9]+[[:space:]]+' | head -n 1) + +if [ -z "${CARD}" ]; then + echo "No sound card found." + exit 1 +fi + +cat > "${FILE}" <<HEREDOC +pcm.!default { + type hw + card $CARD +} +ctl.!default { + type hw + card $CARD +} +timer.!default { + type hw + card $CARD +} +HEREDOC + |