Everyday, when I kick back in my arm chair to meditate, I usually make sure to turn on “Do Not Disturb” mode on both my iPhone and disable notifications on my Mac. That way messages and outside distractions are silenced when I need them to be. It is very important to me that my meditation goes uninterrupted and notifications have a way of happening right when you least expect them to. Unfortunately, I often forget to disable notifications on my Mac and it’s usually just as I’ve pulled up a blanket and closed my eyes. This leads to me having to get up and turn off notifications and then having to start the relaxation process all over again.
I did this today and I thought to myself “There has to be a way to automate this”. So, I postponed my daily nap and got jamming on some research. As I began thinking how to start this automation I was reminded of a technique I saw a while back that used Drafts and Hazel to change the volume on your Mac. You can read about it here. I was then reminded of this post on TUAW about scheduling Do Not Disturb mode with AppleScript and Automator. So, after a bit of searching, I found both articles and got to work combining the techniques for my own purpose.
First off, this automation won’t be for everyone. It requires a few applications that aren’t free (but are awesome) and some nerdiness that some users might not be ready for. Nevertheless, if you’re feeling daring then read on. Here’s the list of what you’ll need to follow along:
- A Mac running Mountain Lion
- An iPhone
- Drafts (iOS)
- Hazel (Mac)
Once you’re setup with the apps and environment detailed above you’ll be ready to go. The first thing I did was grab the two scripts from the TUAW post and modify them for use with Hazel. Namely I just needed to put the code inside of a block like so:
on hazelProcessFile(theFile) — Do stuff here end hazelProcessFile
Then I created a Drafts action to toggle DND mode. BONUS: Click this link on your phone to import the action. My action creates a file called
dnd.txt in a Dropbox folder. In my case thats
/Apps/Drafts although you can set this in the app. I set the action to create a new file and drop the text from my draft into the body of the note.
Then I popped open Hazel on my Mac. After adding the Drafts folder to the folder list I created two rules … one for disabling notifications and another for enabling them. These rules take action depending on what text is found in the contents of the file and can be downloaded here. I used the following codes:
ddnd= disable notifications
ednd= enable notifications
I set the Hazel rules to run the corresponding script if the above codes are found in the file being analyzed. Once the script has been run I also set the rule to move the file to the Trash. After a bit of testing it worked!!
Now when I sit down to meditate, nap, or just don’t want to be disturbed I can just open Drafts, create a new note with the contents
ddnd, trigger my
toggle dnd action and voilà, notifications are disabled on my Mac and I didn’t need to leave my chair! If I want to enable notifications I just do the same thing but type in the code
ednd. Not only was this a practical and useful automation, it also allowed me to try out some techniques I’d never used before. Anybody got any other awesome automations like this? Let me know in the comments.