(* ahpctl - records a buffer of audio while screensaver runs. by 31d1 djbidi@gmail.com version 0.2 app requires Audio Hijack Pro Setup: set the following variable to min recording time in seconds *) set minTime to 30 (* save as an Application, with "Stay Open" checked. Use When launched, will wait until it detects the screensaver is running While screensaver runs, uses AHP to record in chunks of minTime, removing every (n - 2)th chumk When screensaver stops, concatenates the chunks, leaves a wav file on your Desktop, and starts listening again. to close press Cmd-. then Cmd-q. Do not close between screensaver exit and when .wav file is placed on Desktop Note: Allow AHP and this app to keep going after screensaver exits until they close themselves *) repeat while ((do shell script "ps -c -U $(whoami) | awk '/ScreenSaver/'") = "") delay 10 end repeat tell application "Audio Hijack Pro" activate tell application "System Events" set visible of process "Audio Hijack Pro" to false end tell set theSession to make new audio device session at end of sessions set input device of theSession to (first audio input whose name is "Default System Input") set output device of theSession to (first audio output whose name is "Silence Output") set recording format of theSession to {encoding:MP3, bit rate:192, sample rate:44.1, channels:Stereo, style:CBR} set output folder of theSession to "/tmp/" set output name format of theSession to "ahpctl%index" set x to 0 start hijacking theSession start recording theSession delay minTime repeat until ((do shell script "ps -c -U $(whoami) | awk '/ScreenSaver/'") is "") split recording theSession delay minTime set x to (x + 1) if (x > 1) then if (x < 11) then set theFile to "/tmp/ahpctl0" & (x - 1) & ".mp3" else set theFile to "/tmp/ahpctl" & (x - 1) & ".mp3" end if do shell script "rm " & theFile end if end repeat stop recording theSession stop hijacking theSession delete theSession quit end tell do shell script "cat /tmp/ahpctl*.mp3 > ~/Desktop/ahpctl.mp3;rm /tmp/*ahpctl*" set proc to do shell script "me=`whoami`;echo $(ps -U $me | grep ahpctl.app | awk '!/grep/ { print $1 }')" if (proc is not "") then do shell script "kill " & proc & "; open -a ahpctl" end if