Hi,
I'd like to be able to create two actions that allow me to separately mute and dim my speakers. Dimming would ideally be set to a specific volume level.
I tried doing this with the "Press Keys" function but soundflow would not allow me to set of any of the macOS function keys. I also didn't see much in the way of finder scripting.
Is this possible to achieve?
Linked from:
- Chris Shaw @Chris_Shaw2023-03-28 22:46:26.510Z2023-03-29 14:53:27.766Z
I'm assuming you're trying to mute and dim the output of your Mac. if you're trying to mute and dim your interface you'd have to look into your interface's software.
This should dim your system volume (if you change the volume while dimmed, change the volume then un-dim the volume will return to the original volume before dimming)
//dim percentage below is relative to whatever your current volume is // in this case the volume will be 77 percent of the current volume const dimPercentage = 77 function getSystemVolume() { return Math.round(+sf.system.execAppleScript({ script: 'get volume settings' })["Result"].split(",")[0].split(":")[1]); } function dimSystemVolume() { let newSystemVolume if (!globalState.prevSystemVol) globalState.prevSystemVol = getSystemVolume(); if (!globalState.isSysVolumeDimmed) { newSystemVolume = globalState.prevSystemVol * (dimPercentage/100); globalState.dimmedVolume = newSystemVolume; globalState.isSysVolumeDimmed = true log ("Dimmed") } else { newSystemVolume = globalState.prevSystemVol; globalState.isSysVolumeDimmed = false delete globalState.prevSystemVol log ("Un- Dimmed") } sf.system.execAppleScript({ script: `set volume output volume ${Math.round(newSystemVolume)}` }); } dimSystemVolume()
This will toggle the system volume between mute and un-muted:
function toggleSystemAudioMute() { sf.system.execAppleScript({ script: `set curVolume to get volume settings if output muted of curVolume is false then set volume with output muted else set volume without output muted end if`, }); } toggleSystemAudioMute()
- OOmar Gonzalez @Omar_Gonzalez7
Thanks for the reply Chris. Neither scripts are working. This is the log from the mute script
28.03.2023 19:57:16.46 [Backend]: Run command: user:ckz8y90wh0000o310s4q3479y:clft3bwr000003y10qi01kuul
#StreamDeck: deck-button-click -> Mute28.03.2023 19:57:16.46 [Backend]: >> Command: Mute [user:ckz8y90wh0000o310s4q3479y:clft3bwr000003y10qi01kuul]
<< Command: Mute [user:ckz8y90wh0000o310s4q3479y:clft3bwr000003y10qi01kuul]And this is the log for when I run Dim
28.03.2023 19:58:58.93 [Backend]: Run command: user:ckz8y90wh0000o310s4q3479y:clft3c2t400013y10q04kgobt
#StreamDeck: deck-button-click -> Dim28.03.2023 19:58:58.93 [Backend]: >> Command: Dim [user:ckz8y90wh0000o310s4q3479y:clft3c2t400013y10q04kgobt]
JavaScript error with InnerException: null
!! Command Error: Dim [user:ckz8y90wh0000o310s4q3479y:clft3c2t400013y10q04kgobt]:
ReferenceError: getSystemVolume is not defined
(Dim line 4)<< Command: Dim [user:ckz8y90wh0000o310s4q3479y:clft3c2t400013y10q04kgobt]
Chris Shaw @Chris_Shaw2023-03-29 14:51:05.782Z
Sorry about that Omar,
I didn't properly copy/paste the scripts.I've edited and checked the code above. It should work now.
//CS//- OOmar Gonzalez @Omar_Gonzalez7
That seems to be working now. Thank you!