달력

05

« 2012/05 »

  •  
  •  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  •  
  •  


  1. Login as administrator and open a terminal window

  2. Create scriptfile for muting
  3. sudo nano /path/to/mute-on.sh
  4. Enter this as content, when done press control+O to save and control+X to exit:
  5. #!/bin/bash
    osascript -e 'set volume with output muted'
  6. Create scriptfile for unmuting
  7. sudo nano /path/to/mute-off.sh
  8. Enter this as content, when done press control+O to save and control+X to exit:
  9. #!/bin/bash
    osascript -e 'set volume without output muted'
  10. Make both files executable:
  11. sudo chmod u+x /path/to/mute-on.sh
    sudo chmod u+x /path/to/mute-off.sh
  12. Check if any hooks already exist (these will be overwritten, so make sure it is OK for you)
  13. sudo defaults read com.apple.loginwindow LoginHook
    sudo defaults read com.apple.loginwindow LogoutHook
  14. Add hooks for muting
  15. sudo defaults write com.apple.loginwindow LogoutHook /path/to/mute-on.sh
    sudo defaults write com.apple.loginwindow LoginHook /path/to/mute-off.sh


Notes:

- /path/to/ is the location of the scripts, I used /Library/Scripts/

- you can skip the unmuting loginhook (i.e. each logout will silence your machine), but I like it this way because I always have sound available exactly at the volume level I set last time

- root has to be the owner of the script files - running an editor from command line with sudo is the easiest way to achieve that (otherwise you need to chown)

- to delete the hooks, use the following:
sudo defaults delete com.apple.loginwindow LoginHook
sudo defaults delete com.apple.loginwindow LogoutHook



저작자 표시 비영리 동일 조건 변경 허락
Posted by akalune