It loads the launch daemon then creates two files, /etc/rc.sleep and /etc/rc.wakeup. It them moves onto downloading the package and copying the files into the appropriate places. The script begins with deleting any old version of sleepwatcher on the computer. Sudo chmod +x /etc/rc.sleep /etc/rc.wakeup # create script in local user directory and make them executable sudo touch /etc/rc.wakeup # load launch agent sudo launchctl load -w -F /Library/LaunchDaemons/de. Sudo cp config/de. /Library/LaunchDaemons/de. Sudo cp sleepwatcher.8 /usr/local/share/man/man8 # move files into installation folders sudo cp sleepwatcher /usr/local/sbin # create folders necessary for installation sudo mkdir -p /usr/local/sbin /usr/local/share/man/man8 # download sleepwatcher package, untar, and cd into directory curl -remote-name "" tar xvzf sleepwatcher_2.2.tgz 2 >/dev/null Sudo rm -f /usr/local/share/man/man8/sleepwatcher.8 # remove executable and man files sudo rm -f /usr/local/sbin/sleepwatcher # remove plist launchagents sudo rm -f /Library/LaunchDaemons/de. Launchctl unload ~/Library/LaunchAgents/de. 2 >/dev/null # Keep-alive: update existing `sudo` time stamp until `.osx` has finished while true do sudo -n true sleep 60 kill -0 "$$" || exit done 2 >/dev/null & # unload launch agents sudo launchctl unload /Library/LaunchDaemons/de. 2 >/dev/null #!/bin/bash # acquire sudo at the beginning sudo -v ![]() Setupīelow is setup script for sleepwatcher that I have written that installs it automatically as a system wise daemon. ![]() This is to prevent accidental audio playing during meetings and classes. ![]() On my personal laptop, I have an AppleScript set up within sleepwatcher that mutes the audio each time the laptop goes to sleep. Sleepwatcher is a Mac OS X background daemon that can trigger a script to run when various power related events occur, such as the laptop sleeping or waking up, the screen dimming, or power adapter being connected or disconnected.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |