Script to Delay and Stagger the Launch of Login Items Under OS X

AID: 3898
  • Status: Published

2180 points

  • Bynxnw
  • TypeTips/Tricks
  • Posted on2010-10-04 at 15:56:32
If you are using Mac OS X and have a large number of login items set up in accounts, under system preferences, you may find that your computer is sluggish and unresponsive during startup until everything is done launching.

Another problem that arises from time to time is that a login item fails because it requires a resource that is not ready.

The attached script enables you to defer and stagger any or all of your startup items, to alleviate these issues.

Note: It works with a mechanism similar to the OS 9 (and earlier) startup items folder.


How to use the script:
1. make a new folder named "staggeredlaunchitems" in your preferences folder (the one in the library in your home directory).

2. put aliases of the files you want to open or applications you want to launch into the staggeredlaunchitems folder.

3. launch AppleScript editor and paste the attached code snippet into a new AppleScript:
-- this script emulates the OS 9 (and earlier) startup items folder, with the added ability to stagger and delay launches
-- to use this script, 
--   1. make a new folder in your preference folder (the one in the library in your home directory) called (exactly)
--       staggeredlaunchitems
--   2. put aliases of the files you want to open/applications you want to launch into the staggeredlaunchitems
--   3. customize the delays, if desired, in the two "set" commands at the top of the script
--   4. save this script as an application, and make it a login item in (in accounts under system prefs)

set launchdelay to 10 -- change this as required to customize the number of seconds before the first item launches
set itemdelay to 5 -- change this as required to customize the number of seconds between launches

tell application "Finder"
	set launchitemsfolder to (path to preferences folder as string) & "staggeredlaunchitems"
	delay launchdelay
	repeat with x from 1 to (the number of files of folder launchitemsfolder)
		set thefile to (file x of folder launchitemsfolder) as string
		do shell script "open " & (quoted form of POSIX path of thefile)
		delay itemdelay
	end repeat
end tell
quit
                                    
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:

Select allOpen in new window



4. customize the delays, if desired, in the two "set" commands at the top of the script.
  • launchdelay -- the number of seconds before the first item launches.
  • itemdelay -- the number of seconds between each item's launch.


5. save the above script as an application, and make it a login item in accounts, under system preferences.

6. any login items that are now being launched by the script should be removed from the login items pane in accounts, under system preferences.


The files in your staggeredlaunchitems folder will now launch in accordance with the set delays. They will launch in alphabetical order according to the names of the aliases. Change the names of the aliases to change the launch order.

Asked On
2010-10-04 at 15:56:32ID3898
Tags

delay stagger launch login items startup items

Topic

Mac OS X

Views
1660

Comments

Add your Comment

Please Sign up or Log in to comment on this article.

Join Experts Exchange Today

Gain Access to all our Tech Resources

Get personalized answers

Ask unlimited questions

Access Proven Solutions

Search 3.2 million solutions

Read In-Depth How-To Guides

1000+ articles, demos, & tips

Watch Step by Step Tutorials

Learn direct from top tech pros

And Much More!

Your complete tech resource

See Plans and Pricing

30-day free trial. Register in 60 seconds.

Loading Advertisement...

Top Mac OS X Experts

  1. strung

    209,742

    Guru

    2,900 points yesterday

    Profile
    Rank: Genius
  2. eoinosullivan

    92,432

    Master

    1,000 points yesterday

    Profile
    Rank: Genius
  3. maximus5328

    50,329

    Master

    1,000 points yesterday

    Profile
    Rank: Wizard
  4. sigurarm

    31,890

    0 points yesterday

    Profile
    Rank: Sage
  5. ishcabittle

    30,530

    0 points yesterday

    Profile
    Rank: Master
  6. pgnatyuk

    29,332

    0 points yesterday

    Profile
    Rank: Genius
  7. jhyiesla

    22,376

    0 points yesterday

    Profile
    Rank: Genius
  8. mccrick

    17,418

    0 points yesterday

    Profile
    Rank: Guru
  9. Programmer-x

    16,532

    0 points yesterday

    Profile
    Rank: Guru
  10. vallis

    16,104

    0 points yesterday

    Profile
    Rank: Sage
  11. Mac2010

    14,175

    0 points yesterday

    Profile
    Rank: Master
  12. serialband

    12,360

    0 points yesterday

    Profile
    Rank: Master
  13. nxnw

    10,782

    0 points yesterday

    Profile
    Rank: Guru
  14. JonyHolt

    9,543

    0 points yesterday

    Profile
  15. robertcerny

    9,375

    0 points yesterday

    Profile
    Rank: Guru
  16. DaveBaldwin

    9,160

    0 points yesterday

    Profile
    Rank: Genius
  17. nappy_d

    8,700

    0 points yesterday

    Profile
    Rank: Genius
  18. chakko

    8,000

    0 points yesterday

    Profile
    Rank: Genius
  19. arnold

    7,608

    0 points yesterday

    Profile
    Rank: Genius
  20. hanccocka

    7,398

    0 points yesterday

    Profile
    Rank: Genius
  21. Anuroopsundd

    7,118

    0 points yesterday

    Profile
    Rank: Sage
  22. JBlond

    6,960

    0 points yesterday

    Profile
    Rank: Sage
  23. thinkpads_user

    6,768

    0 points yesterday

    Profile
    Rank: Genius
  24. duncan_roe

    6,100

    2,100 points yesterday

    Profile
    Rank: Genius
  25. sweetfa2

    5,868

    0 points yesterday

    Profile
    Rank: Wizard

Hall Of Fame