2022-02-06 11:29:12 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
# Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius)
|
|
|
|
|
|
|
|
. /etc/profile
|
|
|
|
|
2022-11-23 05:35:54 +00:00
|
|
|
# Revert to stored setting when bluetooth was still selected at last shutdown.
|
2022-11-15 04:16:06 +00:00
|
|
|
# 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.
|
2022-11-23 05:35:54 +00:00
|
|
|
LAST_AUDIO_DEVICE=$(set-audio get)
|
|
|
|
if [[ "${LAST_AUDIO_DEVICE}" =~ ^Device.* ]]
|
|
|
|
then
|
|
|
|
set-audio restore
|
|
|
|
fi
|
2022-11-15 04:16:06 +00:00
|
|
|
|
2022-10-22 15:11:33 +00:00
|
|
|
if [ ! -e "/storage/.config/asound.conf" ]
|
2022-10-21 21:23:25 +00:00
|
|
|
then
|
2022-11-12 20:39:58 +00:00
|
|
|
set-audio set "DEFAULT (SYSTEM PROVIDED)"
|
2022-10-22 15:11:33 +00:00
|
|
|
fi
|
2022-10-22 13:45:45 +00:00
|
|
|
|
2022-10-22 15:11:33 +00:00
|
|
|
if [ ! -e "/storage/.config/asound.state" ] && [ -e /usr/config/asound.state ]
|
2022-10-22 13:45:45 +00:00
|
|
|
then
|
2022-10-22 15:11:33 +00:00
|
|
|
cp /usr/config/asound.state /storage/.config
|
2022-10-22 13:45:45 +00:00
|
|
|
fi
|
2022-02-06 11:29:12 +00:00
|
|
|
|
2022-10-22 15:11:33 +00:00
|
|
|
# Initialize sound using the state if available.
|
|
|
|
if [ -e "/storage/.config/asound.state" ]
|
|
|
|
then
|
|
|
|
alsactl restore -f /storage/.config/asound.state
|
2022-05-27 22:33:28 +00:00
|
|
|
fi
|
|
|
|
|
2023-01-21 15:15:01 +00:00
|
|
|
PREAMP=$(get_setting "audio.preamp" 2>/dev/null)
|
|
|
|
amixer -M set Pre-Amp -- ${PREAMP}%
|
2023-01-05 13:35:36 +00:00
|
|
|
|
2022-02-06 11:29:12 +00:00
|
|
|
VOL=$(get_setting "audio.volume" 2>/dev/null)
|
2022-09-22 23:50:28 +00:00
|
|
|
amixer -M set "${DEVICE_AUDIO_MIXER}" ${VOL}%
|