Delay app startup

Joined
Mar 11, 2012
Messages
62
Reaction score
0
Points
6
Your Mac's Specs
MacBookPro early 2012running Mavericks,MacMini Core i7 running Mavericks: iPhone 4s, iPad 3rd Gen
Running Mavericks on MacMini, I keep all "cloud" related folders on my external firewire drive. Sometimes when starting the Mac, it cannot find dropbox or googledrive folders.
I assume it is because the drive has not yet mounted. Is there any way of delaying the start of any program for a few seconds at boot time.
 
Joined
Sep 30, 2007
Messages
9,962
Reaction score
1,235
Points
113
Location
The Republic of Neptune
Your Mac's Specs
2019 iMac 27"; 2020 M1 MacBook Air; macOS up-to-date... always.
OP
T
Joined
Mar 11, 2012
Messages
62
Reaction score
0
Points
6
Your Mac's Specs
MacBookPro early 2012running Mavericks,MacMini Core i7 running Mavericks: iPhone 4s, iPad 3rd Gen
That worked perfectly
Thanks
 
Joined
Oct 11, 2017
Messages
1
Reaction score
0
Points
1
applescript to delay applications until a disk is mounted

Running Mavericks on MacMini, I keep all "cloud" related folders on my external firewire drive. Sometimes when starting the Mac, it cannot find dropbox or googledrive folders.
I assume it is because the drive has not yet mounted. Is there any way of delaying the start of any program for a few seconds at boot time.

Use this AppleScript as a Folder Action script on the /Volumes folder. (To make your Volumes folder visible in the Finder use 'sudo SetFile -a v /Volumes' in terminal, to hide it again change '-a v' to '-a V' and repeat the command)

To configure it you create a folder in /Volumes called 'Sync Apps' that contains another sub-folder named exactly the same as your external hard drive. Any applications you want to start when that external drive is mounted you just put a alias (link) to them inside this sub-folder. You can repeat for as many external drives as you like - just create a folder inside Sync Apps for each external drive and make that folder contain aliases to the apps you want to start up.

So for example - I have an external 4TB thunderbolt raid drive containing my Dropbox Folder, my Google Drive Folder and my Adobe Creative Cloud Folder.
The external drive is called '4TB Raid 1'.

1) I make /Volumes visible and in there I create a folder called 'Sync Apps', then inside that folder I create a sub-folder called '4TB Raid 1'.
2) I create ALIASES to my '/Applications/Dropbox', '/Applications/Backup and Sync from Google' and '/Applications/Adobe Creative Cloud/Adobe Creative Cloud' and drag those aliases into my newly created '/Volumes/Sync Apps/4TB Raid 1' folder
3) In System Preferences I stop Dropbox, Google Drive and Creative Cloud from launching at start up (in User Prefs)
4) I install the following AppleScript as a folder Action on /Volumes and hide the /Volumes folder

Now my cloud apps will start automatically whenever my 4TB Raid 1 drive is mounted, whenever that is - so even if its 10 minutes after a reboot for some reason.

The reason there are sub-folders inside /Volumes/Sync Apps is so you can have multiple external drives - perhaps you have one for dropbox, one for google drive - in which case you just create one sub-folder for each drive and drop the appropriate alias into the right folder.

Once its set up its done.


Code:
on adding folder items to this_folder after receiving added_items
	
	try
		# Get the path to the config folder 'Sync Apps'
		set myConfigFolder to (this_folder as text) & "Sync Apps:"
		
		# Get a list of all the sub-folders in the config folder that we want to look out for
		tell application "Finder"
			set watchList to get name of folders of folder myConfigFolder
		end tell
		
		# Get a simple string of the newly added items for quick searching
		set addedList to (added_items as text)
		
		# For each sub-folder name in the config folder, see if it is in the added list
		repeat with watchFolder in watchList
			set watchPath to (this_folder as text) & watchFolder & ":"
			if addedList contains watchPath then
				# We matched, build the alias to the config/watch folder containing the apps
				set myAppFolder to myConfigFolder & watchFolder & ":"
				# Get a list of all the apps in there
				tell application "Finder"
					set theAppList to get name of files of folder myAppFolder
				end tell
				repeat with theApp in theAppList
					tell application "Finder"
						activate
						open alias file (myAppFolder & theApp)
					end tell
				end repeat
			end if
		end repeat
	end try
end adding folder items to
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top