repeat -- main event loop
repeat -- loop when no call is present or Skype is not running
if (callInProgress()) then
exit repeat
else
delay 15 -- sleep for 15 seconds before checking again
end if
end repeat
-- initiate recording here between repeat loops
-- you are on your own for this one
-- I don't have the Piezo application
repeat
if (not callInProgress()) then
exit repeat
else
delay 15 -- Skype keeps ports open for about 60 seconds after a call ends. Recording will end somewhere between 60 and 75 seconds after talking stops.
end if
end repeat
-- The only way you get to this line is if there was a recording initiated that has now ended.
-- Tell Piezo to turn the recording off.
end repeat
on callInProgress()
set pid to do shell script "ps -Af | grep Skype | grep -v grep | cut -d ' ' -f 4"
if ((pid as text) is "") then
return false
end if
set skypeOpenFilesCount to do shell script "lsof -p " & pid & " | grep ESTAB | wc -l"
ignoring white space
set openNumber to skypeOpenFilesCount as number
end ignoring
if (openNumber > 5) then
return true
log ("talking")
else
return false
log ("not talking")
end if
end callInProgress