Open Source

In System Preferences > Sound > Sound Effects, users have the choice to turn off user interface sound effects (as an example, that might be a “tick” sound when adjusting a slider, or a “lock/unlock” sound when clicking a Lock button).

But how do you respect that setting? NSSound surely doesn’t.
Well, I found two ways to do it:

The “Easy” Way

macOS has a key in the standard UserDefaults object

com.apple.sound.uiaudio.enabled

If it is present and set to true, it’s safe to play the ui sound.

The “Safe” Way

What if the UserDefaults key isn’t present? Or you just want to be absolutely certain that your sound respects the user’s setting?

Use the AudioToolbox APIs. It offers

AudioServicesSetProperty(kAudioServicesPropertyIsUISound,...)

which marks sounds as UI sounds, thus not playing if the user wishes them not to.

It’s a bit more work, but might be the safer way to do it.

Read more

For my freeware app SiriMote (which lets you control your Mac and its apps with your Apple TV Remote), I created a code-drawn representation of Apple TV’s Siri Remote (versions 2015-2021).

I figured, sharing is caring, so here you go, you can get at it over on GitHub.

It’s written in Objective-C, was built with Xcode 12.5.1 and runs on macOS 10.12.2 and newer.

Enjoy šŸ˜Š

Read more

For Transloaderā€™s upcoming version 3.0, I needed an NSMenuItem that not only showed a title, but also a subtitle, along with an optional image.

Because it took a bit of work and ā€œreverse-engineeringā€ (the click-on-an-item-selection-animationā€™s timing, in particular), I figured someone else might benefit from this.

Where to get it / Sample Project

Itā€™s all pretty straight forward, and best shown / explained as an Xcode project, which you can download on Github.
This is basically all you need to do:

Screenshot the sample project's source code

Thatā€™s it!

Caveats

There are some things this implementation can not do, which the default NSMenuItem can:

  • There is no type select
  • The arrow keys canā€™t be used to go through the items
  • You canā€™t activate items with the space or enter keys

Basically, keyboard interaction is unavailable.

I do hope itā€™s useful to you anyways.
If youā€™re using this, Iā€™d love to hear from you! šŸ˜Š

Read more