I just want the volume to go up and down please

You the know the feeling, you just got yourself a schmancy new mechanical keyboard, you have configured it, flashed it… and why oh why does my monitor show a greyed out speaker icon when I press VOL+ or VOL-?

TL;DR: Use a Fn key bound to Applescript, disable conflicting keys, manually run the script for every app that you own.

Ok, first stop, the interwebs tells me the problem me that media keys only adjust the overall system volume and since I have set my sound output to use the monitor I am s*!t out of luck. I could setup some kind of loopback service / app to route audio through which then goes to the monitor but then I would still have to somehow bind keys to that service.

But hang on, all I am doing is wanting to turn the iTunes volume up and down… and iTunes has shortcuts for that e.g. cmd + <Up> (when in the app) - surely we can talk to me old mate iTunes directly?

Second stop, let’s try and specifically write some Applescript to do this ahem total Applescript noob alert cough:

on run {input, parameters}
  tell application "iTunes"
    if the sound volume is less than 100 then
      set sound volume to (sound volume + 8)
      set sound volume to 100
    end if
  end tell
  return input
end run

(this is just for volume up, volume down is same-ish, basically taken from here )

Throw that into a new service via Automator (hah, didn’t even know that was a thing, how neat, can you tell I used to be a Windows lad?)

Let’s bind this to F15 (I thought this would be fine - when have I ever used F15 for anything?) and we can do quite easily via System Preferences > Keyboard > Shortcuts > Services > General.

…and it doesn’t work.

However, if one runs the script by clicking on the common Services menu item and then iTunes Volume Up (what I named the script service) it works.

Ok, right, let’s see if something else is bound to F15 via the age old method of stumbling around and yep Increase display brightness is mapped so since it is relatively easy let’s reflash the keyboard to instead use F23 and F24 - surely nobody-got-those-mapped fingers crossed.

Hoo-kinda-ray?! Bah, it seems to only work in the app from whence I previously checked from…and the interwebs confirms this is indeed a standing macOS bug. And now, FINALLY, once I manually run the script from the Services menu in most (? I don’t know any more, plz halp) of my other programs the shizzle works.

I kind of feel that some kind of computers suck, amirite? remark is fitting here - I mean I am totally off in the yak shaving weeds here with a custom mechanical keyboard, firmware flashing, Applescript and services so really I am sitting in my own hole / grave / cesspit - but this was actually achieved in approximately the time it took to write this blog post (let’s pretend this would also be possible for someone who hadn’t been doing the computer thang for 30ish years)… and this was kind of fun and satisfying to get going.