2023-08-06 23:29:18 +00:00
|
|
|
#!/bin/sh
|
2023-10-23 22:44:47 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
2023-08-06 23:29:18 +00:00
|
|
|
# Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius)
|
|
|
|
|
2023-09-04 14:54:35 +00:00
|
|
|
. /etc/profile
|
2023-08-06 23:29:18 +00:00
|
|
|
|
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 20:59:29 +00:00
|
|
|
### Auto switch between internal and bluetooth devices
|
2023-09-04 14:54:35 +00:00
|
|
|
pactl load-module module-switch-on-connect 2>/dev/null
|
2023-08-08 20:59:29 +00:00
|
|
|
|
2023-08-09 12:10:06 +00:00
|
|
|
### Set up audio routing (Internal or HDMI)
|
2023-09-04 14:54:35 +00:00
|
|
|
/usr/bin/hdmi_sense 2>/dev/null
|
2023-08-08 15:59:42 +00:00
|
|
|
|
2023-08-07 12:02:33 +00:00
|
|
|
### Set the default audio path, needed for some devices
|
|
|
|
if [ ! -z "${DEVICE_PLAYBACK_PATH_SPK}" ]
|
|
|
|
then
|
2023-08-12 15:34:32 +00:00
|
|
|
if [ -z "${DEVICE_PLAYBACK_PATH}" ]
|
|
|
|
then
|
2023-09-04 14:54:35 +00:00
|
|
|
export DEVICE_PLAYBACK_PATH="Playback Path"
|
2023-08-12 15:34:32 +00:00
|
|
|
fi
|
2023-09-04 14:54:35 +00:00
|
|
|
amixer -c 0 cset name="${DEVICE_PLAYBACK_PATH}" ${DEVICE_PLAYBACK_PATH_SPK} 2>/dev/null
|
2023-08-07 12:02:33 +00:00
|
|
|
fi
|
|
|
|
|
2023-08-06 23:29:18 +00:00
|
|
|
VOLUME=$(get_setting audio.volume)
|
2023-09-04 19:08:01 +00:00
|
|
|
if [ -z ${VOLUME} ]
|
2023-08-06 23:29:18 +00:00
|
|
|
then
|
|
|
|
VOLUME="60"
|
2023-09-04 19:08:01 +00:00
|
|
|
elif [ -n "${DEVICE_VOLUME}" ]
|
2023-08-07 15:57:50 +00:00
|
|
|
then
|
|
|
|
VOLUME="${DEVICE_VOLUME}"
|
2023-08-06 23:29:18 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
/usr/bin/volume ${VOLUME}
|
|
|
|
|