Skip to content

Instantly share code, notes, and snippets.

@chris-roerig
Created August 12, 2015 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chris-roerig/81bab017d710ed69a926 to your computer and use it in GitHub Desktop.
Save chris-roerig/81bab017d710ed69a926 to your computer and use it in GitHub Desktop.
mac osx audio mute toggler
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