more fixes

This commit is contained in:
deadcade 2024-12-01 16:52:03 +01:00
parent 29ebf51d2a
commit 6d4599a746
2 changed files with 21 additions and 13 deletions

View file

@ -1,11 +1,11 @@
# Maintainer: 0xDEADCADE <$(base64 -d<<<MHhkZWFkY2FkZUBwcm90b25tYWlsLmNvbQ==)> # Maintainer: 0xDEADCADE <$(base64 -d<<<MHhkZWFkY2FkZUBwcm90b25tYWlsLmNvbQ==)>
pkgname=headsetcontrol-chatmixd-git pkgname=headsetcontrol-chatmixd-git
_pkgname=${pkgname%-git} _pkgname=${pkgname%-git}
pkgver=r1.2cab32f pkgver=r1.d79fb51
pkgrel=1 pkgrel=1
pkgdesc="A bash daemon to control volume of different applications through the Chatmix wheel." pkgdesc="A bash daemon to control volume of different applications through the Chatmix wheel."
arch=('any') arch=('any')
url="https://github.com/0xDEADCADE/${_pkgname}" url="https://g.deadca.de/deadcade/${_pkgname}"
license=('GPLv3') license=('GPLv3')
provides=("$_pkgname") provides=("$_pkgname")
conflicts=("$_pkgname") conflicts=("$_pkgname")
@ -24,5 +24,5 @@ package() {
cd $pkgname cd $pkgname
install -D -m755 "$_pkgname" "$pkgdir/usr/bin/$_pkgname" install -D -m755 "$_pkgname" "$pkgdir/usr/bin/$_pkgname"
install -D -m644 LICENSE "$pkgdir/usr/share/licenses/$_pkgname/LICENSE" install -D -m644 LICENSE "$pkgdir/usr/share/licenses/$_pkgname/LICENSE"
install -D -m644 "${_pkgname}.service" "$pkgdir/usr/lib/systemd/user/" install -D -m644 "${_pkgname}.service" "$pkgdir/usr/lib/systemd/user/${_pkgname}.service"
} }

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# Config # Config
_pollingInterval=1 _pollingInterval=0
_chatmixCenter=64 _chatmixCenter=64
_chatmixCenterSize=5 _chatmixCenterSize=5
_debug=1 _debug=1
@ -9,10 +9,12 @@ _voicechatSink="Voicechat_chatmixd"
_gameSink="Game_chatmixd" _gameSink="Game_chatmixd"
# Internal vars # Internal vars
_running=0 _running=false
_centerMin=$((_chatmixCenter - _chatmixCenterSize)) _centerMin=$((_chatmixCenter - _chatmixCenterSize))
_centerMax=$((_chatmixCenter + _chatmixCenterSize)) _centerMax=$((_chatmixCenter + _chatmixCenterSize))
declare -A _known_devices declare -A _known_devices
_voicechatSinkModule=""
_gameSinkModule=""
# Main loop # Main loop
update() { update() {
@ -20,7 +22,7 @@ update() {
local _chatmix=$2 local _chatmix=$2
local _old_chatmix=${_known_devices["${_model}"]} local _old_chatmix=${_known_devices["${_model}"]}
_known_devices["${_model}"]=${_chatmix} _known_devices["${_model}"]=${_chatmix}
[[ ${_running} -eq 0 ]] && return [[ ! ${_running} ]] && return
[[ ${_debug} -eq 1 ]] && printf "Model: %s Chatmix: %s -> %s\n" "${_model}" "${_old_chatmix}" "${_chatmix}" [[ ${_debug} -eq 1 ]] && printf "Model: %s Chatmix: %s -> %s\n" "${_model}" "${_old_chatmix}" "${_chatmix}"
[[ "${_chatmix}" == "${_old_chatmix}" ]] && return [[ "${_chatmix}" == "${_old_chatmix}" ]] && return
@ -61,22 +63,28 @@ main() {
fi fi
# Link up sinks to default sink, try to avoid looping # Link up sinks to default sink, try to avoid looping
if [[ "$DEFAULT_SINK" != *"${_voicechatSink}"* ]] && [[ "$DEFAULT_SINK" != *"${_gameSink}"* ]]; then if [[ "$DEFAULT_SINK" != *"${_voicechatSink}"* ]] && [[ "${_defaultSink}" != *"${_gameSink}"* ]]; then
pw-link "${_voicechatSink}:monitor_FL" "$DEFAULT_SINK:playback_FL" pw-link "${_voicechatSink}:monitor_FL" "${_defaultSink}:playback_FL"
pw-link "${_voicechatSink}:monitor_FR" "$DEFAULT_SINK:playback_FR" pw-link "${_voicechatSink}:monitor_FR" "${_defaultSink}:playback_FR"
pw-link "${_gameSink}:monitor_FL" "$DEFAULT_SINK:playback_FL" pw-link "${_gameSink}:monitor_FL" "${_defaultSink}:playback_FL"
pw-link "${_gameSink}:monitor_FR" "$DEFAULT_SINK:playback_FR" pw-link "${_gameSink}:monitor_FR" "${_defaultSink}:playback_FR"
fi fi
while true; do _running=true
while ${_running}; do
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source <(headsetcontrol -o ENV) source <(headsetcontrol -o ENV)
update "${DEVICE_0}" "${DEVICE_0_CHATMIX}" update "${DEVICE_0}" "${DEVICE_0_CHATMIX}"
sleep ${_pollingInterval} sleep ${_pollingInterval}
_running=1
done done
}
trap close INT TERM
function close() {
pactl unload-module "${_voicechatSinkModule}" pactl unload-module "${_voicechatSinkModule}"
pactl unload-module "${_gameSinkModule}" pactl unload-module "${_gameSinkModule}"
_running=false
} }
main main