distribution/packages/sysutils/system-utils/sources/devices/RK3566/headphone_sense
2023-08-14 15:52:03 +00:00

33 lines
913 B
Bash

#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2020-present Shanti Gilbert (https://github.com/shantigilbert)
# Copyright (C) 2021-present Fewtarius
# Source predefined functions and variables
. /etc/profile
HP_ON='*headset status is in*'
HP_OFF='*headset status is out*'
# Switch to headphones if we have them already connected at boot
BOOT_SETTING=$(journalctl | grep "headset status is" | tail -n 1)
case ${BOOT_SETTING} in
(${HP_ON})
amixer -c 0 cset name='Playback Path' ${DEVICE_PLAYBACK_PATH_HP}
;;
*)
amixer -c 0 cset name='Playback Path' ${DEVICE_PLAYBACK_PATH_SPK}
;;
esac
journalctl -f | while read line; do
case $line in
(${HP_ON})
amixer -c 0 cset name='Playback Path' ${DEVICE_PLAYBACK_PATH_HP}
;;
(${HP_OFF})
amixer -c 0 cset name='Playback Path' ${DEVICE_PLAYBACK_PATH_SPK}
;;
esac
done