6

I know how to run a program on boot, on login (System > Preferences > Startup Applications) or on opening a shell (.bashrc). I also did read "execute script after desktop loaded?". What I realized that every application added to Startup Applications extends the time until the desktop becomes usable. So I'm looking for a way to start all the "nice to haves" from a script (got that working) that runs after the regular startup is finished.

I'm not fully clear how to get there. Would I use a second script that calls the first one with & (so it runs in the background) and add a wait for (a few seconds|specific event) to the first one?

stwissel
  • 6,451

2 Answers2

2

Just call sleep at the beginning of your "nice-to-haves" script. That shouldn't block the desktop from loading. You may also be able to speed things up on multi-core hardware by backgrounding each process.

e.g.

sleep 20s
<something that takes a long time> &
<this can now start immediately> &
...

The two commands will run in parallel, but they'll wait for 20 seconds before starting. You can use "m", "h", or "d" to specify minutes, hours, or days if a few seconds isn't what you had in mind. =)

1

If you're going to launch something expensive, launch it in the background with a delay. For example

after 20s find-all-the-dirty-dishes &
after 1m find ~ -name '*~' -mtime +30 -exec rm '{}' ';'

where you will have to implement after yourself but it can be something like this

#!/bin/sh
sleep "$1"
shift
exec "$@"