ah I didn't have socat installed.
Could you try using the full path to socat and jq? I'm not sure what environment variables are set when running through apple script. They might also differ when being run through terminal via osascript
e.g.
if (get name of every application process) contains "IINA" then
-- Define the socket path and command to check if playback is paused
set mpvSocket to "/tmp/mpv-socket"
set pauseCommand to "{ \"command\": [\"get_property\", \"pause\"] }"
set trueValue to "true"
set falseValue to "false"
-- Send the get property command and capture the response
tell application "System Events"
set pauseResponse to do shell script "echo '" & pauseCommand & "' | /opt/homebrew/bin/socat - " & mpvSocket & " | /opt/homebrew/bin/jq -r '.data'"
end tell
-- Check if the response is true or false
if pauseResponse = trueValue then
-- Send command to set pause to false
tell application "System Events"
do shell script "echo '{ \"command\": [\"set_property\", \"pause\", false] }' | /opt/homebrew/bin/socat - " & mpvSocket
end tell
else
-- Send command to set pause to true
tell application "System Events"
do shell script "echo '{ \"command\": [\"set_property\", \"pause\", true] }' | /opt/homebrew/bin/socat - " & mpvSocket
end tell
end if
return
end if
It seems to work fine here