From d59643353c421eaeda87724c5880e0bd8a128524 Mon Sep 17 00:00:00 2001 From: Sebastian Kiesel Date: Sun, 13 Aug 2023 17:07:32 +0200 Subject: [PATCH] workaround for Audacity stealing focus on AddLabel --- bin/muxsa-vr | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/bin/muxsa-vr b/bin/muxsa-vr index bf85495..9db24b9 100755 --- a/bin/muxsa-vr +++ b/bin/muxsa-vr @@ -112,10 +112,18 @@ trap 'kill "${RECEIVE_FROM_AUDACITY_PID}"' EXIT ##### # LABEL is assumed to be a global variable holding an integer value -set_label_text_audacity () { +add_label_with_text_to_audacity () { local L="${LABEL:-"0"}" local T="$(printf "%04d" ${LABEL:-"0"})" + + # first observed with audacity 3.2.4 on Debian bookworm + # audacity steals the input focus when labels are added / changed + FOCUSEDWINID=$(xdotool getwindowfocus) + send_to_audacity 'AddLabel' send_to_audacity "SetLabel: Label=${L} Selected=0 Text=\"${T}\"" + sleep 0.3 + echo "Trying to get the focus back to ${FOCUSEDWINID}" + xdotool windowfocus "${FOCUSEDWINID}" } ############################################################################ @@ -181,8 +189,7 @@ while true ; do CLIPS[0]=0 send_to_audacity 'NewMonoTrack' send_to_audacity 'NewLabelTrack' - send_to_audacity 'AddLabel' - set_label_text_audacity + add_label_with_text_to_audacity send_to_audacity 'SelAllTracks' ;; @@ -233,10 +240,9 @@ while true ; do else echo "Adding label at end while paused" send_to_audacity 'CursTrackEnd' - send_to_audacity 'AddLabel' LABEL=$(( ${LABEL} + 1 )) CLIPS[$LABEL]=0 - set_label_text_audacity + add_label_with_text_to_audacity send_to_geeqie 'next' fi ;; @@ -277,8 +283,7 @@ while true ; do send_to_audacity 'SelPrevClipBoundaryToCursor' send_to_audacity 'Delete' echo "Re-install deleted label" - send_to_audacity 'AddLabel' - set_label_text_audacity + add_label_with_text_to_audacity CLIPS[$LABEL]=0 ;; *)