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