def write_launchd_plist
      say "Setting up launchd configuration file #{PLIST_FILE}..."
      Dir.mkdir(File.dirname(PLIST_FILE)) unless File.directory?(File.dirname(PLIST_FILE))
      plist = <<-PLIST
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
	"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>org.rubygems.sheepsafe</string>
	<key>ProgramArguments</key>
	<array>
		<string>#{sheepsafe_bin_path}</string>
	</array>
	<key>WatchPaths</key>
	<array>
		<string>/Library/Preferences/SystemConfiguration</string>
	</array>
        <!-- We specify PATH here because /usr/local/bin, where grownotify -->
        <!-- is usually installed, is not in the script path by default. -->
        <key>EnvironmentVariables</key>
        <dict>
                <key>PATH</key><string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/bin</string>
        </dict>
</dict>
</plist>
PLIST
      File.open(PLIST_FILE, "w") {|f| f << plist }
    end
def write_launchd_plist
      say "Setting up launchd configuration file #{PLIST_FILE}..."
      Dir.mkdir(File.dirname(PLIST_FILE)) unless File.directory?(File.dirname(PLIST_FILE))
      plist = <<-PLIST
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
	"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>org.rubygems.sheepsafe</string>
	<key>ProgramArguments</key>
	<array>
		<string>#{sheepsafe_bin_path}</string>
	</array>
	<key>WatchPaths</key>
	<array>
		<string>/Library/Preferences/SystemConfiguration</string>
	</array>
        <!-- We specify PATH here because /usr/local/bin, where grownotify -->
        <!-- is usually installed, is not in the script path by default. -->
        <key>EnvironmentVariables</key>
        <dict>
                <key>PATH</key><string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/bin</string>
        </dict>
</dict>
</plist>
PLIST
      File.open(PLIST_FILE, "w") {|f| f << plist }
    end
Write a launchd plist file to .~/Library/LaunchAgents/sheepsafe.plist.

 For details see http://tech.inhelsinki.nl/locationchanger/