#!/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 cset name='Playback Path' ${DEVICE_PLAYBACK_PATH_HP} ;; *) amixer cset name='Playback Path' ${DEVICE_PLAYBACK_PATH_SPK} ;; esac journalctl -f | while read line; do case $line in (${HP_ON}) amixer cset name='Playback Path' ${DEVICE_PLAYBACK_PATH_HP} ;; (${HP_OFF}) amixer cset name='Playback Path' ${DEVICE_PLAYBACK_PATH_SPK} ;; esac done