Posts RSS Comments RSS 48 Posts and 155 Comments till now

Archive for October, 2010

Opening a FaceTime connection via AppleScript/Automator

The new FaceTime video chat beta is now available from Apple. It allows you to video chat with anyone using that app on any Mac running the service as well as an iPhone 4 or the latest iPod running iOS 4 or better. It’s extremely easy and I can see a lot of great uses for it.

One of the very cool things about it is that you can use a URL to initiate a FaceTime call. As described in this Mac OS X Hints article just use the following syntax:

  • facetime://appleid
  • facetime://email@address
  • facetime://phone# as a URL in Safari’s address bar.

Since you can use a URL that means you can use AppleScript to connect to a session or Automator to even schedule and initiate a call using iCal Alarms.

The only line you need is this:

[codesyntax lang=”applescript] open location “facetime://joe@emailaddress.com”[/codesyntax]

Obviously you can use any of the URL syntaxes listed above in place of the email address. Save it as a script/application/workflow and you’re ready to chat!

How to back up Address Book automatically

For quite a while now you’ve been able to manually backup your entire Address Book. This has saved many people massive heartache when they’ve had their machines go down/did an OS re-install or various other scary things (Yeah, I know, if you have MobileMe you don’t need to do this but most people don’t).

The big issue with backing up this way, as with any backup, is getting people to do it and do it regularly. To backup your Address Book all you need to do it copy the /Users/”user name”/Library/Application Support/AddressBook folder in each users home directory. Simple, direct and easy. But you may have noticed that when you do a manual backup via the Address Book application you get a file with the “.abbu” extension. That’s just the AddressBook folder renamed and getting that extension. The beauty of having this file is when you want to restore your Address Book via the menu you can just point to this file. Otherwise you have to drag the backed up folder to the original spot. Again, not hard to do but some users have problems doing things that go outside of clicking on a menu item.

So, to back up your Address Book and put it in nice “.abbu” file for easy restores just do this:
[codesyntax lang=”bash”]
filedate=`/bin/date “+%m-%d-%y”`
cp -R “/Users/username/Library/Application Support/AddressBook” “/Users/username/Documents/Address Book Backups/Address Book Backup $filedate.abbu”
[/codesyntax]

Obviously you change the “username” section to the name of the home directory. Also, you can change the backup folder to what ever you want. This script just appends the current date to the backup so you can keep multiple backups if needed.

To run this you have a bunch of options:

  1. You can run it via cron or launchd. Just put the two lines together and seperated by a “;”.
  2. You can run it as an Automator iCal plug-in. Just drag over the “Run Shell Script” action and paste in the script. Then schedule it via iCal.
  3. You can save it as a script and run it from what ever automation application you prefer.

Check how much disk space is left using AppleScript

This is a fairly simple one but someone out there may need this. My boss recently had a weird problem where his disk was suddenly filling up. A reboot fixed it but we were having a hard time finding the process that was suddenly eating 15 GB of disk space with no warning. So, I came up with this script that just gets how much free space is left on his disk. We ran it as a cron job every 15 minutes so we could hopefully get some warning before things filled up and became unusable. The script displays a warning when the disk has 5% or less of free space. You can edit it for your own uses. It also has the ability to email the report to you. Comment out the section you don’t want to use. To have it send emails when you are not logged in use something like Lingon for a launchd item or Cronnix for a cron job. Save your script in the appropriate location and have the launchd/cron job call it using the “osascript” command. So, if the file was saved in the /Users/Shared folder the line would read:

osascript /Users/Shared/disk_check.scpt

[codesyntax lang=”applescript”]
set mysubject to “Disk Usage Report”
set myrecipient to “sysadmin@example.com”

–get the amount of free space
set dSize to (do shell script “df -h / | grep %”) as text

–pull out the percent used from the result
set theTotal to word 6 in dSize as number

–if the total used space is 95% or more put up a warning. Comment out if running the email section
if theTotal is greater than or equal to 95 then
display dialog “Your disk is ” & theTotal & “% full”
end if

–comment out this section if no email is desired.
set mybody to (“Free Space: ” & theTotal & “%”)
do shell script (“echo \”” & mybody & “\” | mail -s \”” & mysubject & “\” ” & myrecipient)
[/codesyntax]

Click here to download a copy: Disk Check script