Skip to content

Instantly share code, notes, and snippets.

@haraldmartin
Created November 27, 2010 16:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haraldmartin/718027 to your computer and use it in GitHub Desktop.
Save haraldmartin/718027 to your computer and use it in GitHub Desktop.
Set active Time Machine Disk
property pth : (path to preferences folder from local domain) as text
property d1name : "WD My Book"
property d1 : "com.apple.TimeMachine RF9.plist"
property d2name : "AirDisk"
property d2 : "com.apple.TimeMachine Home.plist"
property active : "com.apple.TimeMachine.plist"
on growl_it(foo)
tell application "GrowlHelperApp"
set the allNotificationsList to {"Disk Changed"}
set the enabledNotificationsList to allNotificationsList
register as application ¬
"Time Machine Disk Switcher" all notifications allNotificationsList ¬
default notifications enabledNotificationsList ¬
icon of application "Time Machine"
notify with name ¬
"Disk Changed" title ¬
"Time Machine Disk Changed" description ¬
"Active Disk is now \"" & foo & "\"" application name "Time Machine Disk Switcher"
end tell
end growl_it
do shell script "defaults write com.apple.TimeMachine AutoBackup -bool false"
if (list disks) contains d1name then
tell application "Finder" to if exists (pth & d1) then
-- set name of file (pth & active) to d2
-- set name of file (pth & d1) to active
set cmd1 to "mv \"" & POSIX path of (pth & active) & "\" \"" & POSIX path of (pth & d2) & "\"; true"
set cmd2 to "mv \"" & POSIX path of (pth & d1) & "\" \"" & POSIX path of (pth & active) & "\"; true"
do shell script cmd1
do shell script cmd2
delay 2
if exists (pth & d1) then
my growl_it("Failed to rename TimeMachine.plist file. Retrying with sudo (disabled for now)…")
--do shell script cmd1 with administrator privileges
--do shell script cmd2 with administrator privileges
end if
my growl_it(d1name)
else
my growl_it("failed because " & pth & d1 & " doesnt exit")
end if
else
tell application "Finder" to if exists (pth & d2) then
--set name of file (pth & active) to d1
--set name of file (pth & d2) to active
-- delay 2
set cmd1 to "mv \"" & POSIX path of (pth & active) & "\" \"" & POSIX path of (pth & d1) & "\"; true"
set cmd2 to "mv \"" & POSIX path of (pth & d2) & "\" \"" & POSIX path of (pth & active) & "\"; true"
do shell script cmd1
do shell script cmd2
if exists (pth & d2) then
my growl_it("Failed to rename TimeMachine.plist file. Retrying with sudo (disabled for now)…")
--do shell script cmd1 with administrator privileges
--do shell script cmd2 with administrator privileges
end if
my growl_it(d2name)
else
my growl_it("failed because " & pth & d2 & " doesnt exit")
end if
end if
do shell script "defaults write com.apple.TimeMachine AutoBackup -bool true"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment