distribution/packages/jelos/autostart/005-audio
2023-08-08 12:13:09 +00:00

40 lines
933 B
Bash
Executable file

#!/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
tocon "Configuring Audio..."
STATE=$(systemctl isactive pipewire-pulse)
if [ "${STATE}" = "inactive" ]
then
systemctl start pipewire-pulse
fi
DEFAULT_SINK=$(pactl list short sinks | awk '! /hdmi/ {print $2; exit}')
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
### 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
VOLUME=$(get_setting audio.volume)
if [[ -z ${VOLUME} ]]
then
VOLUME="60"
elif [[ -n "${DEVICE_VOLUME}" ]]
then
VOLUME="${DEVICE_VOLUME}"
fi
/usr/bin/volume ${VOLUME}