Skip to content

Instantly share code, notes, and snippets.

@yene
Last active August 29, 2015 14:25
Show Gist options
  • Save yene/76f5b1673682be6a120b to your computer and use it in GitHub Desktop.
Save yene/76f5b1673682be6a120b to your computer and use it in GitHub Desktop.
Check when the last Time Machine Backup was and display notification
// use it in calender: http://apple.stackexchange.com/a/59265/14030
app = Application.currentApplication()
app.includeStandardAdditions = true
ObjC.import('Cocoa')
dict = $.NSDictionary.dictionaryWithContentsOfFile('/Library/Preferences/com.apple.TimeMachine.plist')
firstItem = dict.valueForKey('Destinations').firstObject
lastBackup = firstItem.valueForKey('SnapshotDates').lastObject
diff = lastBackup.timeIntervalSinceNow // in seconds
diff = (diff * -1)
if (diff > 60*60*24*3) {
app.displayNotification('Last Backup is more than 3 days old.' ) //, {withTitle: 'BACKUP'}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment