Page 1 of 1

Mute Mac Volume

PostPosted: Tue Jun 11, 2019 11:19 pm
by koburg
I want to make a Schedule to turn the volume for the Mac running indigodomo down (MUTE) is there any way to do this ?

have tried searching the forum no luck so far.

Re: Mute Mac Volume

PostPosted: Tue Jun 11, 2019 11:39 pm
by koburg
thanks but also want to know how to do it in python

because of what yourself mentioned.

Re: Mute Mac Volume

PostPosted: Wed Nov 17, 2021 5:28 pm
by wideglidejrp
I have the same need. Anybody find a way to do this?

Re: Mute Mac Volume

PostPosted: Thu Nov 18, 2021 8:04 am
by McJohn
You can do this with a simple external AppleScript (sorry):

Code: Select all
tell application "Finder" to set volume 0


Or via a more complex way:
https://dev.to/kojikanao/control-mac-so ... python-h4g

BTW: we are using Airfoil and the Indigo Airfoil plugin to control all the speakers/volume through the whole house, works perfect.

John

Re: Mute Mac Volume

PostPosted: Thu Nov 18, 2021 3:32 pm
by wideglidejrp
I don't see how Finder can change the Mac volume. Also, I don't want to use an AppleScript. The other solution you describe may be just what I have been looking for. What I am trying to do is mute my Mac from an action group. I tried to install osascript but it did not work. Also, does osascript support python?

Re: Mute Mac Volume

PostPosted: Tue Nov 30, 2021 10:45 am
by jay (support)
There is no built-in way for Python to do this. osascript is also a command line utility that's installed with macOS, and that's probably the best bet. You can call it from python:

Code: Select all
import os
os.system("/usr/bin/osascript -e 'tell application \"Finder\" to set volume 0'")

Re: Mute Mac Volume

PostPosted: Sat Dec 04, 2021 2:11 pm
by wideglidejrp
This solution works perfectly in my Python script. The question I have is how does it work? I am not aware of any actions I can take with Finder to change system volume. Is it a hidden command?

Re: Mute Mac Volume

PostPosted: Sat Dec 04, 2021 2:13 pm
by FlyingDiver
The Finder is just the app that's providing the interface for scripting for the sound system. AppleScript targets apps, so they had to put it somewhere. It does the same things as the volume control keys.

Also, there are menu bar controls for volume. What app is that?

Re: Mute Mac Volume

PostPosted: Wed May 04, 2022 2:29 pm
by rustyhodge
All you actually need is:
Code: Select all
import os
os.system("/usr/bin/osascript -e 'set volume 0'")