Skip to content

Instantly share code, notes, and snippets.

@fvdm
Last active January 27, 2016 08:06
Show Gist options
  • Select an option

  • Save fvdm/36d4bdf47aab502d5a3a to your computer and use it in GitHub Desktop.

Select an option

Save fvdm/36d4bdf47aab502d5a3a to your computer and use it in GitHub Desktop.
// Only copy new images to another folder:
require ('osx-photostream') ('~/Pictures/iCloud');
// Do more stuff with them:
var ps = require ('osx-photostream') ();
ps.on ('update', function (file) {
console.log ('New image added: ' + file.filename);
};)
// Or do both and first copy to another folder,
// then tell another app a new image is ready using AppleScript.
var ps = require ('osx-photostream') ('~/Pictures/iCloud');
var exec = require ('child_process').exec;
ps.on ('copy', function (file) {
// Forward image to friend
exec ('osascript -e "tell application \"Messages\" to send POSIX file \"' + file.copypath + '\" to buddy \"friend@email.tld\" of service \"E:my@email.tld\""');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment