You're right, that was a bad suggestion. If I thought harder I knew that and not sure why I even suggested that. I have tried that many times years ago trying to get that darn function key to work for other things. Karabiner was working before it got locked out by macOS and slowly got back to close to where it was with KarabinerElements.
That was a great resource you shared so thank you. I have put that down for my notes for future reference.
Here's another alternative approach for at least the mute key.
That's unnecessarily slow. You're spawning an AppleScript instance to do the test, then spawning another AS instance to mute/unmute.
Since you're toggling the "muted" setting and the output muted property is a boolean, you can do it all in one line of AS:
set volume output muted (not output muted of (get volume settings))
I was also going to say that spawning a shell that then spawns an AS is also inefficient. Luckily I checked first and they're almost the same. Which makes sense when you think about it because KM executes AppleScripts via osascript -- we're doing explicitly what a KM AS action does anyway.
All three variants so you can play with timings -- enable whichever action inside the "Repeat" you want to test, disable the others: