distribution/packages/sysutils/system-utils/sources/devices/RK3399/video_sense

39 lines
1 KiB
Text
Raw Normal View History

2023-08-08 13:12:27 +00:00
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2022-present JELOS (https://github.com/JustEnoughLinuxOS)
2023-08-08 13:12:27 +00:00
. /etc/profile
# 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
2023-10-31 22:48:49 +00:00
HDMI=$(pactl list sinks short | grep hdmi | cut -c 0-2)
SPEAKER=$(pactl list sinks short | grep es8316 | cut -c 0-2)
2023-08-08 13:12:27 +00:00
# Check HDMI plugged / unplugged, set audio output, restart Emulation Station
HDMI_VALUE=$(cat /sys/class/gpio/gpio${DEVICE_HDMI_GPIO}/value)
while true
do
HDMI_NEW_VALUE=$(cat /sys/class/gpio/gpio${DEVICE_HDMI_GPIO}/value)
if test "${HDMI_VALUE}" != "${HDMI_NEW_VALUE}"
then
case ${HDMI_NEW_VALUE} in
"0") #HDMI plugged
2023-10-31 22:48:49 +00:00
pactl set-default-sink ${HDMI}
2023-08-08 13:12:27 +00:00
;;
"1") #HDMI unpluagged
2023-10-31 22:48:49 +00:00
pactl set-default-sink ${SPEAKER}
2023-08-08 13:12:27 +00:00
;;
esac
2023-11-01 05:06:15 +00:00
killall emulationstation
2023-08-08 13:12:27 +00:00
HDMI_VALUE=${HDMI_NEW_VALUE}
fi
sleep 5
done