swaync-fbcli: fix CPU pegging

This commit is contained in:
Colin 2024-04-15 18:09:21 +00:00
parent 827c50ff43
commit 824046aca1

View File

@ -28,21 +28,22 @@ start() {
trap cleanup SIGINT SIGQUIT SIGTERM
local extraFbcliArgs=()
local timeout=
case "$event" in
phone-incoming-call)
extraFbcliArgs=("-t" "20")
timeout=20
;;
*)
;;
esac
local cli="fbcli --event $event ${timeout:+ -t $timeout}"
# feedbackd stops playback when the caller exits
# and fbcli will exit immediately if it has no stdin.
# so spoof a stdin.
# TODO: this maybe pegs CPU at 100% when receiving a call, and never exits?
log "fbcli --event $event ${extraFbcliArgs[*]}"
/bin/sh -c "true | fbcli --event $event ${extraFbcliArgs[*]}" &
log "$cli"
/bin/sh -c "sleep $((3 ${timeout:+ + $timeout})) | $cli" &
child=$!
wait
}