Title
Mute/Un Mute Speakers and log
What do you expect to happen when you run the script/macro?
This script mutes and un mutes my speakers. Script works great!
Are you seeing an error?
What happens when you run this script?
My speakers get muted and un muted. I would like to add a log function that tells me if I muted or un muted the speakeres
How were you running this script?
I used a Stream Deck button
How important is this issue to you?
3
Details
{ "inputExpected": "This script mutes and un mutes my speakers. Script works great!", "inputIsError": false, "inputWhatHappens": "My speakers get muted and un muted. I would like to add a log function that tells me if I muted or un muted the speakeres", "inputHowRun": { "key": "-MpfwmPg-2Sb-HxHQAff", "title": "I used a Stream Deck button" }, "inputImportance": 3, "inputTitle": "Mute/Un Mute Speakers and log" }
Source
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()
Links
User UID: aMkTBTHB3he77TafFWFI244Jm9j1
Feedback Key: sffeedback:aMkTBTHB3he77TafFWFI244Jm9j1:-NSSSmYZqoxbfqp4WQbL
- OOmar Gonzalez @Omar_Gonzalez7
This is a similar script that someone here wrote for me that dims my speakers. Notice that it has a log function. I would like to add that to the mute script
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)}` });
Brenden @nednednerb
I cannot speak for how to format the AppleScript; that's not a SoundFlow thing.
Why don't you use the script you shared? Does it not work? If it works, why adapt the AppleScript?
https://stackoverflow.com/questions/13653358/how-to-log-objects-to-a-console-with-applescript
The above post says "AppleScript does not make it easy" to log to a console.SF can run other kinds of script, but I think that's most useful for Apple OS inner working-centric functions, rather than to log something for SF console.
I could see you making additional variables in SF based on whether a totally new AppleScript actually runs. But it seems to be a back and forth between AppleScript Code and SF code JUST for a log message. Hence, again, why don't you use the "similar script"? If it doesn't work, it seems like it almost might. It "looks" well written at first glance.
- OOmar Gonzalez @Omar_Gonzalez7
The mute script works fine. The dim script gives me a sound flow notification that say's "dimmed" and "un-dimmed" when used respectively. I want to add that functionality to the mute script because it's nice to see, and I know its possible to have since the dim script has it
- In reply toOmar_Gonzalez7⬆:Raphael Sepulveda @raphaelsepulveda2023-04-08 22:52:41.374Z
@Omar_Gonzalez7, here you go!
function toggleSystemAudioMute() { const state = sf.system.execAppleScript({ script: `set curVolume to get volume settings if output muted of curVolume is false then set volume with output muted return "System Audio Muted" else set volume without output muted return "System Audio Unmuted" end if`, }).result; return { state }; } log(toggleSystemAudioMute().state);
- OOmar Gonzalez @Omar_Gonzalez7
Thank you Raphael!