distribution/packages/jelos/sources/autostart/common/005-alsa
2022-11-20 14:41:15 -05:00

35 lines
1.1 KiB
Bash
Executable file

#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius)
. /etc/profile
### REMINDER: This needs to be refactored or it will break audio on other devices.
# Revert to default when bluetooth was still selected at last shutdown.
# This is a workaround - headsets that auto-connect at boot tend to be
# unreliable, so for now it's better to force a manual reconnect.
#LAST_AUDIO_DEVICE=$(set-audio get)
#if [[ "${LAST_AUDIO_DEVICE}" =~ ^Device.* ]]
#then
# set-audio set "DEFAULT (SYSTEM PROVIDED)"
# set-audio esset "DEFAULT (SYSTEM PROVIDED)"
#fi
if [ ! -e "/storage/.config/asound.conf" ]
then
set-audio set "DEFAULT (SYSTEM PROVIDED)"
fi
if [ ! -e "/storage/.config/asound.state" ] && [ -e /usr/config/asound.state ]
then
cp /usr/config/asound.state /storage/.config
fi
# Initialize sound using the state if available.
if [ -e "/storage/.config/asound.state" ]
then
alsactl restore -f /storage/.config/asound.state
fi
VOL=$(get_setting "audio.volume" 2>/dev/null)
amixer -M set "${DEVICE_AUDIO_MIXER}" ${VOL}%