1

Is there a clean way to detect whether the default output device (on Mac OS X) is being muted via a ruby program?

I know I can make a system call to an applescript or mangle together something with objective-c cocoa calls. But I'd like something built-in or a tried-and-true gem.

Alec Jacobson
  • 6,032
  • 5
  • 51
  • 88

1 Answers1

1

There are a couple Ruby to AppleScript gems:

According to Avoiding AppleScript through Ruby: rb-appscript or rubyosa?, Appscript is superior, but neither is compiling cleanly for me (OSX 10.10.2, Ruby 2.2.2), and this is a very simple use case, so I'd go with your own call out to osascript. The RubyTunes gem to control iTunes from Ruby went this direction, and the AppleScript sound controls are easy:

osascript -e "output muted of (get volume settings)"
false
Kristján
  • 18,165
  • 5
  • 50
  • 62
  • I want to avoid applescript since it invokes launchservicesd which is power intensive. I'd like to call this many times a minute and the applescript version is draining my battery. – Alec Jacobson Jul 26 '15 at 03:26