1

I like it when my Mac announces the time every hour. It keeps me focused or provides me with a reminder to take a break. I also like it when Mail makes a sound when new messages arrive so I can check them. I like all these sounds when I'm using my computer.

What I don't like is these sounds when I'm not using my computer mainly because my Mac is in my bedroom. Usually the solution is simply to mute the Mac before bed but I sometimes forget and am woken up by an announcement telling me the time or letting me know new mail is in during the middle of the night.

Without putting my computer to sleep (I want it awake at all times when plugged in so it can do things I need it to do), is there any way my Mac can mute its sound when it is idle (or more preferably idle for some period of time)?

2

I wanted the same and didn't find anything nice, so I coded an app for myself. You can find the code here and already as compiled app here.

Let me know what you think.

|improve this answer|||||
1

iCal alarms can be used to activate an AppleScript.

If you're simply concerned with forgetting to unmute the Mac in the morning, set an alarm to fire this script at the appointed hour:

set volume without output muted

The opposite command, which sets the sound to "muted", is set volume with output muted. Set an alarm that activates that at night and you'll be set.

|improve this answer|||||
0

I haven't tested this, but you might run EDITOR=nano crontab -e and add a line like this:

*/5 * * * * test $(ioreg -c IOHIDSystem|awk '/HIDIdleTime/{printf "\%i",$NF/1000000000;exit}') -ge 300 && pmset -g assertions|grep -q 'PreventUserIdleSystemSleep *0'&&osascript -e 'set volume with output muted'

*/5 * * * * runs the command every five minutes. HIDIdleTime shows how much time has passed since you have for example pressed a key on a keyboard or moved a mouse. There is a PreventUserIdleSystemSleep assertion when you are for example playing music in iTunes or watching a video in VLC.

The command does not unmute the output volume when you start using the computer though.

|improve this answer|||||

You must log in to answer this question.