Last active
December 15, 2015 22:39
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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