Execute a Shell Script Action (v11.0.3)

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.

Execute a Shell Script Action (v11.0.3)

Execute a Shell Script.kmactions (991 B)

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:

Volume Setting Speed Test.kmmacros (6.1 KB)

Image

Simulate Hardware Key:

2 Likes

That's cool, the AppleScript was the fastest but on an M4 they were all very fast!

I have to remembrer that timing test to use in the future thanks for sharing.

Does this do something like the AppleScript in @Nige_S post in the background?

set volume output muted (not output muted of (get volume settings))

No, it simulates the hardware key - after that the system handles it however the system handles it.

1 Like

That's very cool that you can do that, thank you for sharing.