diff options
| author | 2024-11-02 18:53:17 +0000 | |
|---|---|---|
| committer | 2024-11-02 18:53:17 +0000 | |
| commit | c9d15be9602603d34e457818f150b23d0666e77b (patch) | |
| tree | 59756a77d66a874720facd60bccb1dc2bdc52322 | |
| parent | f14e066ace042cf2b24773499d472c8a6ccc1f81 (diff) | |
For each audio backend (pipewire, pulse), require existence of relevant
tool (wpctl, pactl)
| -rwxr-xr-x | swob.sh | 27 |
1 files changed, 12 insertions, 15 deletions
@@ -58,6 +58,15 @@ glob_match() { test $# -gt 1 -o -e "$1" } +select_audio() { + # could guess at /run/user/`id -u`, but let's not jump the gun here + sound_sys=$1 rundir=${2:-$XDG_RUNTIME_DIR} tool=$3 + test -n "$rundir" && + glob_match "$rundir/$sound_sys"* && + command -v "$tool" >/dev/null 2>&1 && + SWOB_AUDIO=$sound_sys +} + get_audio_type() { # MUST be called with set +fu @@ -67,21 +76,9 @@ get_audio_type() { *) echo >&2 "$0: warning: unrecognised SWOB_AUDIO: $SWOB_AUDIO" ;; esac - # could guess at /run/user/`id -u`, but let's not jump the gun here - rundir=${PIPEWIRE_RUNTIME_DIR:-$XDG_RUNTIME_DIR} - if test -n "$rundir" && glob_match "$rundir"/pipewire*; then - SWOB_AUDIO=pipewire - return - fi - - rundir=${PULSE_RUNTIME_PATH:-$XDG_RUNTIME_DIR} - if test -n "$rundir" && glob_match "$rundir"/pulse*; then - SWOB_AUDIO=pulse - return - fi - - # default to ALSA - SWOB_AUDIO=alsa + select_audio pipewire "$PIPEWIRE_RUNTIME_DIR" wpctl && return + select_audio pulse "$PULSE_RUNTIME_PATH" pactl && return + SWOB_AUDIO=alsa # default to ALSA } set_vol() { |
