AppleScripting Notification Center > Scheduling Do Not Disturb
Mountain Lion’s Notification Center is great for keeping you in the loop, but it can be a huge distraction when you need to get stuff done. Sometimes, a little peace and quiet is all you need to stay productive.
As you may know, iOS 6 includes a handy Do Not Disturb feature, which can be turned on to disable notifications. It can even be set to automatically enable/disable itself at scheduled intervals. Mountain Lion also lets you disable Notification Center. Just open Notification Center and drag down to access a Show Alerts and Banners toggle switch. Note that this is a temporary setting, and disabled notifications automatically re-enable at midnight.
Unlike iOS 6, though, Mountain Lion doesn’t give you an option for enabling/disabling notifications on a schedule. At least, it doesn’t provide a built-in option for this. With a little customized help from AppleScript, Automator, and the Calendar app, it is possible.
In this post, you’ll create two Calendar Alarm Automator workflows, which can be configured to run at scheduled times to enable or disable Notification Center alerts and banners.
Note: If you have any trouble following along, you can download the completed AppleScripts and Automator workflows here.
Building a Workflow to Enable Do Not Disturb (i.e. Disable Notification Center Alerts and Banners)
1. Launch Automator (in your /Applications folder) and create a new Calendar Alarm workflow.
2. Search the action library for the Run AppleScript action and drag it to the workflow area.
3. Replace the pre-filled AppleScript code in the Run AppleScript action with the following:
The script writes to Notification Center’s property list file and enables Do Not Disturb mode. It then quits and relaunches Notification Center in order for the change to go into effect.
4. You’re finished building the workflow, so go ahead and save it as Enable Do Not Disturb.
5. When you save the workflow, Automator puts it where it needs to go (the ~/Library/Workflows/Applications/Calendar folder). The Calendar app launches and a new event is created in an Automator calendar, which Automator creates if it doesn’t already exist. The event should be configured with an Open File alarm that’s set to run the workflow. Schedule the event for the desired time, such as every weekday morning at 6 AM.
Now, every time the event occurs, the alarm should launch the workflow and Notification Center should be disabled. As I mentioned earlier, Notification Center automatically re-enables each day at midnight. So, if you plan to schedule Do Not Disturb overnight, then you’ll need to create an additional event that disables it again at 12:01 AM.
Building a Workflow to Disable Do Not Disturb (i.e. Re-Enable Notification Center Alerts and Banners)
Now that you’ve got a workflow to disable Notification Center, you probably want one to re-enable it.
1. Create another new Calendar Alarm workflow in Automator.
2. Search the action library for the Run AppleScript action again and drag it to the workflow area.
3. This time, replace the existing placeholder script in the Run AppleScript action with the following code:
This code updates Notification Center’s property list file to disable Do Not Disturb. Then, it relaunches Notification Center for the change to take effect.
4. The workflow is done, so save it as Disable Do Not Disturb.
5. The Calendar app should launch again and another event should be added to the Automator calendar. This event should be configured with an Open File alarm that’s set to open the Disable Do Not Disturb workflow. Set it to run on the desired schedule, such as every weekday morning at 9 AM.
If everything has gone according to plan, you should now have Do Not Disturb workflows that disable and re-enable Notification Center alerts and banners at the desired times. Use your alert-free time wisely. Until next time, happy scripting!
AppleScripting Notification Center > Scheduling Do Not Disturb originally appeared on TUAW – The Unofficial Apple Weblog on Mon, 04 Feb 2013 07:00:00 EST. Please see our terms for use of feeds.
- Download iOS 7.0.6
- How To Jailbreak iOS 7 – 7.0.6 Untethered On iPhone 5s, 5c, 5, 4s And More With Evasi0n7
- How To Downgrade iOS 7 To iOS 6.1.3 / 6.1.4
- How To Jailbreak iOS 6.1.3 On iPhone 4, iPod touch 4 and iPhone 3GS Using Redsn0w
- How To Jailbreak iOS 6.0 to 6.1.2 Untethered On iPhone 4,3GS, iPod touch 4 Using Sn0wbreeze 2.9.11
- How To Jailbreak iOS 6.1.2 Untethered On iPhone 5,4S, iPad, iPod touch Using Evasi0n 1.5
- How To Jailbreak iOS 6 With Official Cydia On iPhone 4, iPhone 3GS And iPod touch 4G Using Redsn0w 0.9.15b1