2022-10-02 16:46:51 +00:00
|
|
|
#!/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})
|
2022-10-21 11:37:01 +00:00
|
|
|
amixer cset name='Playback Path' ${DEVICE_PLAYBACK_PATH_HP}
|
2022-10-02 16:46:51 +00:00
|
|
|
;;
|
|
|
|
*)
|
2022-10-21 11:37:01 +00:00
|
|
|
amixer cset name='Playback Path' ${DEVICE_PLAYBACK_PATH_SPK}
|
2022-10-02 16:46:51 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
journalctl -f | while read line; do
|
|
|
|
case $line in
|
|
|
|
(${HP_ON})
|
2022-10-21 11:37:01 +00:00
|
|
|
amixer cset name='Playback Path' ${DEVICE_PLAYBACK_PATH_HP}
|
2022-10-02 16:46:51 +00:00
|
|
|
;;
|
|
|
|
(${HP_OFF})
|
2022-10-21 11:37:01 +00:00
|
|
|
amixer cset name='Playback Path' ${DEVICE_PLAYBACK_PATH_SPK}
|
2022-10-02 16:46:51 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|