Skip to content

Instantly share code, notes, and snippets.

@maxx
Last active December 15, 2015 22:39
Show Gist options
  • Save maxx/5334178 to your computer and use it in GitHub Desktop.
Save maxx/5334178 to your computer and use it in GitHub Desktop.
applescript to vary vlc volume based on load average (for ambient sound representing load avg)
to getLoadAvgsResult()
return do shell script "(uptime | awk '{print $10}' | cut -d \",\" -f 1)"
end getLoadAvgsResult
set last_load to getLoadAvgsResult()
repeat 999 times
set current_load to getLoadAvgsResult()
log last_load
log current_load
set diff to last_load - current_load
if (diff > 0.05 and current_load > 2) then
tell application "VLC" to volumeDown
log "down"
else
if (diff < -0.05 and current_load < 3) then
tell application "VLC" to volumeUp
log "up"
end if
end if
set last_load to current_load
delay 5
end repeat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment