distribution/packages/hardware/quirks/devices/Anbernic RG552/sleep.d/post/001-audio
2023-11-01 05:06:15 +00:00

30 lines
846 B
Bash

#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
# Workaround for no audio on wake from sleep.
. /etc/profile
HDMI=$(pactl list sinks short | grep hdmi | cut -c 0-2)
SPEAKER=$(pactl list sinks short | grep es8316 | cut -c 0-2)
#Set sink to one we aren't currently using
pactl set-default-sink ${SPEAKER}
#Then check if HDMI is plugged and switch to HDMI
# Set export GPIO for HDMI
if [ ! -d "/sys/class/gpio/gpio${DEVICE_HDMI_GPIO}" ]; then
echo ${DEVICE_HDMI_GPIO} > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio${DEVICE_HDMI_GPIO}/direction
fi
# Check HDMI plug state and switch to HDMI audo if true
HDMI_VALUE=$(cat /sys/class/gpio/gpio${DEVICE_HDMI_GPIO}/value)
case ${HDMI_VALUE} in
"0")
sleep 11
pactl set-default-sink ${HDMI}
;;
esac