Mute volume of macbook on sleep I was wondering if there was any way to mute my macbook whenever I physically close it, so if there was anything playing prior to closing it that it does not continue to make noise when I open it later.

Seems like a weird request, but I have a bad habit of forgetting to pause my music/youtube  when I leave for class, than when I open my laptop in class it disrupts the class. 

The easy answer would be, "just pause your stuff", but I thought it would be nice if there was something that could accomplish this.
Download SleepWatcher (free, source code included).
Install it using the instructions included in the download.
Have your 'sleep' script call osascript (AppleScript)

/usr/bin/osascript -e 'set volume with output muted'


Now your Mac will be muted anytime your computer goes to sleep.

If you want to make extra sure that it is muted when it wakes from sleep, add

/usr/bin/osascript -e 'set volume with output muted'


to your 'wake' script as well.