Schedule your Mac to mute sound at night
Last night my email client was on and my MacBook Pro’s volume was set to full volume (I was rocking out during a coding session earlier in the day) and every time my email client Sparrow got a new email it would chime an alert. Typically I welcome this alert but no at midnight, 1:15, 2:22, 3:45, 4:55. So the 4:55am one did help me wake up this morning but that’s beside the point.
I know I can somehow control the volume using applescript and I know I can assign a script to be kicked off at certain times by setting a scheduled even in iCal so I thought I should marry these to ideas and stop my Mac from bothering my wife an I at night.
Here is how I did it:
Open up the AppleScript Editor, I used Spotlight to do this…
Once you have that open type in the following:
set volume 0
You can test if this works by setting your volume to the max from the menu bar or on your keyboard. Now press the “Run” button and watch the magic happen.TaDa! Volume set to zero. Obviously we don’t want to run this script manually each time we want this to happen so let’s save this script to your Documents folder, I named mine “Mute Sound.scpt” and move on to iCal.
Close the AppleScript Editor and load up iCal.
If this automation thing is new to you I’d imagine you’ll be using this more and more, go up to File and select New Calendar and then select “On My Mac”. Why “On My Mac”? well for me I sync all my calendars to my iPhone and iPad and I dont want to be alerted when my Mac is doing these automations so we’re making a mac specific calendar to house these. Set the name of this Calendar to be “Automation”.
After that right click on todays date and select “New Event” and name it “Mute Sound” then double click on it and select “Edit”.
From the edit screen set the time you want your computer to be muted, for me I set it for 10pm since I’m old and go to bed a decent hour most nights. Since I want this to happen “most nights” you can set this to run say, Sunday through Thursday for 10pm like me then on Friday through Saturday set it for 11:59pm or whatever fits your schedule. To do the 2 tier’d scheduling just make 2 events. Anyhow, to kick off the Alert change the Alert to “Run Script” and then locate the “Mute Sound” script from your Documents folder.
Click apply and now you have your Mute Sound kicking off at the time you specified and now you won’t be bothered late at night.
In a later posting I’ll discuss how to use AppleScript and iCal to update my podcasts each morning so they are ready for me to listen to on my commute to work.
Let me know how this works for you in the comments below!