How to Schedule a Shortcut on Mac to Mute Volume Automatically at Night

https://youtu.be/8TsHZpTd-Y8

The Shortcuts App on iOS has an automation section that lets you schedule shortcuts to run at a certain time. On the Mac, Shortcuts application lacks this ability.

The other morning, my Mac calendar notification went off, and it woke up my wife.

To prevent this, I wanted to make a shortcut that ran every evening to mute the volume on my Mac.

Create the Shortcut

It is a simple shortcut to set the volume to zero percent.

Create a simple mute volume shortcut.

Running Shortcuts from the command line

What you can do is run Shortcuts from the command line and given this capability it means you can schedule it to be run.

shortcuts run "Mute Volume"

Scheduling the Shortcut

There are multiple ways to schedule processes on the Mac, and I decided to use launchd Dameon with launchctl. I chose this because this is the most “native” Mac way of scheduling.

Launched relies on a property list file (“plist”) in a certain format. An example format is below:

<?xml version="1.0" encoding="UTF-8"?>

<plist version="1.0">
<dict>
<key>Label</key>
<string>org.deverman.mutevolumeshortcut</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/shortcuts</string>
<string>run</string>
<string>Mute Volume</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>1</integer>
<key>Minute</key>
<integer>0</integer>
</dict>
</dict>
</plist>

After the “run” parameter you can change “Mute Volume” to your shortcut name.

Then you can change the hour and minute integers for when you would like the shortcut to run. There are other configurations that you can research online for other scheduling options.

Edit the above XML in a text editor and save it to the following location:

~/Library/LaunchAgents/

You should come up with a reverse domain name as a unique name for this run. I named my shortcut as:

org.deverman.mutevolumeshortcut

Save it in the above folder with a “.plist” suffix:

~/Library/LaunchAgents/org.deverman.mutevolumeshortcut.plist

The to get the system to recognize this you can run this command:

launchctl load ~/Library/LaunchAgents/org.deverman.mutevolumeshortcut.plist

This showed me that in System Settings ->Login Items & Extensions that the shortcut was active:

In System Settings Login Items & Extensions shows your new shortcut launcher.

You can even disable the shortcut here if necessary without editing the plist file.

Ensure the Mac wakes up to run the shortcut

Below is the command you should run to ensure your MacBook is awake when your shortcut runs. You will need to enter your system root password.

sudo pmset repeat wakeorpoweron MTWRFSU 00:59:00

This will make sure your computer is awake Monday (M) through Sunday (U) at 12:59am.

Managing and Validating with Lingon Application

For an extra $24USD, there is an app that manages “.plist” launchd files called Lingon Pro. This is probably great if you want to do more complex scheduling settings.

Lingon Allows you to view your shortcut launch settings.

Summary

It’s a lot of work to schedule a shortcut. Hopefully, Apple will put more attention on shortcuts so we can avoid this, but until then, this should help.