2023-08-06 23:29:18 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
# Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius)
|
|
|
|
|
|
|
|
# Minimal OS variable loading for performance
|
|
|
|
. /etc/profile.d/02-distribution
|
|
|
|
|
2023-08-07 11:12:57 +00:00
|
|
|
tocon "Configuring Audio..."
|
|
|
|
|
2023-08-08 00:15:56 +00:00
|
|
|
STATE=$(systemctl isactive pipewire-pulse)
|
|
|
|
if [ "${STATE}" = "inactive" ]
|
|
|
|
then
|
|
|
|
systemctl start pipewire-pulse
|
|
|
|
fi
|
2023-08-06 23:29:18 +00:00
|
|
|
|
2023-08-08 15:59:42 +00:00
|
|
|
DEFAULT_ID=$(pactl list short cards | awk '! /hdmi/ {print $1; exit}')
|
2023-08-08 12:13:09 +00:00
|
|
|
DEFAULT_SINK=$(pactl list short sinks | awk '! /hdmi/ {print $2; exit}')
|
2023-08-08 15:59:42 +00:00
|
|
|
|
2023-08-08 12:13:09 +00:00
|
|
|
if [ ! -z "${DEFAULT_SINK}" ]
|
|
|
|
then
|
|
|
|
### Set the default sink ignoring HDMI
|
|
|
|
pactl set-default-sink ${DEFAULT_SINK}
|
|
|
|
pactl set-default-source ${DEFAULT_SINK}.monitor
|
|
|
|
fi
|
|
|
|
|
2023-08-08 15:59:42 +00:00
|
|
|
if [ ! -z "${DEVICE_PIPEWIRE_PROFILE}" ]
|
|
|
|
then
|
|
|
|
pactl set-card-profile ${DEFAULT_ID} ${DEVICE_PIPEWIRE_PROFILE}
|
|
|
|
fi
|
|
|
|
|
2023-08-07 12:02:33 +00:00
|
|
|
### Set the default audio path, needed for some devices
|
|
|
|
if [ ! -z "${DEVICE_PLAYBACK_PATH_SPK}" ]
|
|
|
|
then
|
|
|
|
amixer cset name='Playback Path' ${DEVICE_PLAYBACK_PATH_SPK}
|
|
|
|
fi
|
|
|
|
|
2023-08-06 23:29:18 +00:00
|
|
|
VOLUME=$(get_setting audio.volume)
|
|
|
|
if [[ -z ${VOLUME} ]]
|
|
|
|
then
|
|
|
|
VOLUME="60"
|
2023-08-07 15:57:50 +00:00
|
|
|
elif [[ -n "${DEVICE_VOLUME}" ]]
|
|
|
|
then
|
|
|
|
VOLUME="${DEVICE_VOLUME}"
|
2023-08-06 23:29:18 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
/usr/bin/volume ${VOLUME}
|
|
|
|
|