Created
April 20, 2010 20:39
-
-
Save logandk/373039 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>com.dropbox.preferences</string> | |
<key>OnDemand</key> | |
<true/> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/usr/bin/ruby</string> | |
<string>/Users/[USERNAME]/Dropbox/Preferences/Scripts/copy_plists.rb</string> | |
</array> | |
<key>RunAtLoad</key> | |
<true/> | |
<key>WatchPaths</key> | |
<array> | |
<string>/Users/[USERNAME]/Library/Preferences</string> | |
<string>/Users/[USERNAME]/Dropbox/Preferences</string> | |
</array> | |
</dict> | |
</plist> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'fileutils' | |
require 'pathname' | |
# Configuration | |
preference_files = %w( | |
com.apple.Terminal.plist | |
com.macromates.textmate.plist | |
com.panic.Transmit3.plist | |
) | |
# Set paths for preferences and dropbox mirror | |
preference_root = Pathname.new(ENV['HOME']).realpath.join('Library', 'Preferences') | |
dropbox_root = Pathname.new(ENV['HOME']).realpath.join('Dropbox', 'Preferences') | |
# Overwrite newer files from preferences to dropbox and vise-versa | |
preference_files.each do |filename| | |
pfile = preference_root + filename | |
dfile = dropbox_root + filename | |
FileUtils.cp(pfile, dfile, :preserve => true) if pfile.exist? and !dfile.exist? | |
FileUtils.cp(dfile, pfile, :preserve => true) if dfile.exist? and !pfile.exist? | |
if pfile.mtime > dfile.mtime | |
puts "Copied #{pfile} (#{pfile.mtime}) to #{dfile} (#{dfile.mtime})" | |
FileUtils.cp(pfile, dfile, :preserve => true) | |
elsif dfile.mtime > pfile.mtime | |
puts "Copied #{dfile} (#{dfile.mtime}) to #{pfile} (#{pfile.mtime})" | |
FileUtils.cp(dfile, pfile, :preserve => true) | |
end | |
end | |
# Delay next operation | |
sleep 30 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment