Created
August 12, 2015 16:38
-
-
Save chris-roerig/81bab017d710ed69a926 to your computer and use it in GitHub Desktop.
mac osx audio mute toggler
This file contains 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
class Muter | |
def mute_for(minutes = 5) | |
return restore if minutes == 0 | |
Thread.new do | |
mute | |
sleep (minutes * 60) | |
restore | |
end | |
end | |
def mute | |
`osascript -e 'set volume output muted true'` | |
end | |
def restore | |
`osascript -e 'set volume output muted false'` | |
end | |
end | |
Muter.new.mute_for(ARGV[0].nil? ? nil : ARGV[0].to_i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment