Support for mac media keys

MOC version: 
2.5.2

Would it be possible to support the mac media keys natively?

Akin to mpv's input-media-keys option
It works wonderfully!

I can have a look at what MPV does (and thanks for that link), but it won't be any time soon.

Also, I don't have a Mac upon which to develop or test and have only ever used one once (back in the 1990s) and then only very briefly, so I have no idea at this stage how feasible it would be or what the user would expect results of its use should be.

However, if someone wants to chip in and provide it (and will actually be able to do something without handholding from me) then they should feel free to contact mocmaint.

Thanks for the reply.

As of right now I have no way of using the media keys, as they can't be used for shortcuts, which stops me from usinc moc.

Hopefully somebody chips in :)

I've now looked at the patch with implements this in MPV, and there are several things which disturb me.

According to that patch, the API used is not public and the hardcoded values used were determined by reverse engineering. This makes the implementation quite fragile, IMHO. Also, it implements a quite limited functionality.

That said, the patch was committed back in 2013 and things may have changed in the last six years but that was not within the scope of my investigation.

It also mentions Quartz Event Taps about which I know nothing (and I'm guessing is OSX-specific). In short, the implementation in MOC would involve components of a software ecosystem in which I have absolutely no experience. I think my limited time would be more effectively used to move forward features within MOC which are applicable to a wider audience.

(I e-mailed my MOC-friendly, HomeBrew contributor asking for advice but have not received a reply to date.)

Thanks for looking into it.

The Quartz Event Taps does indeed look difficult to implement without having access to the OS.

I would be happy with an option to just use the hard-coded media keys without it. The reason is because I actually disable iTunes, since I never use it. So the media keys are free to whatever program is active at the time.
Of course this would have to be an option.

While it's impossible to support media keys natively in a curses application, I think there might be a workaround to achieve similar effects from outside MOC.

Note that MOC playback could be controlled programmatically:

mocp --play
mocp --pause
mocp --next
mocp --prev

And on macOS keys (but not the media control keys) can be bound to arbitrary Automator workflows, which could execute shell commands.

So, it might be possible to use a third party keymapper, e.g., Karabiner Elements[1] to remap the media control keys to bindable keys (not sure if possible, I don't use this myself, but I did find some promising references), then bind to Automator workflows to control MOC playback. Failing that, you could make standard function keys the default (System Preferences -> Keyboard -> Use F1, F2...), which are definitely bindable; same keys, but that assumes you don't frequently use other feature keys.

[1] https://github.com/pqrs-org/Karabiner-Elements

This is a great insight. Thank you!