Linux

How to Launch Startup Applications With A Delay On Linux


Delay startup applications Linux

This article explains how to delay startup applications, with 2 ways of achieving this.

1. Add a startup delay to applications using X-GNOME-Autostart-Delay

Some desktop environments, like GNOME, support an autostart parameter, called X-GNOME-Autostart-Delay, to start applications with a delay after login.

This works in GNOME, Unity, MATE, Cinnamon and other desktop environments, but not all. KDE and Xfce don’t support this for example. Some of these already come with a startup delay option in the Startup Applications GUI, like MATE or Cinnamon desktops:

startup delay Cinnamon
Startup delay option on Cinnamon desktop (Linux Mint)

For other desktop environments, where the startup delay option is not available in the GUI, you can manually edit the autostart desktop file to add this parameter yourself. 

Look for the autostart desktop file in either ~/.config/autostart for your user, or /etc/xdg/autostart for all users, open the file with a text editor, like Nano (e.g. nano ~/.config/autostart/<myapp>.desktop) and add this to the file without modifying anything else:

X-GNOME-Autostart-Delay=<xx>

Where xx is the startup delay you want to add to this application, in seconds.

Example autostart desktop entry to which I’ve added X-GNOME-Autostart-Delay with a delay of 10 seconds:

[Desktop Entry]
Name=MyApp
GenericName=My app
Comment=Application to do something
Exec=myapp
Terminal=false
Type=Application
Icon=myapp
Categories=GNOME;GTK;Utility
X-GNOME-Autostart-Delay=10

You might also like: KDE Connect / GSConnect: How To Lock/Unlock Your Linux Desktop Using An Android Device

2. Add a startup delay to some applications using sleep

If your desktop environment doesn’t support the X-GNOME-Autostart-Delay parameter, there’s a generic way you can use to launch applications on startup with a delay.

To do this, look for the application / command autostart desktop file in either ~/.config/autostart for your user, or /etc/xdg/autostart for all users. You’ll need to open this file with a text editor (as root if it’s from /etc/xdg/autostart) to add a startup delay.

In this autostart desktop file, modify the Exec value like this: bash -c "sleep <xx> && <original_command>". Where xx is the number of seconds to add as a startup delay for that original_command.

Example startup desktop file in which I’m running the “MyApp” application with a 7-second startup delay:

[Desktop Entry]
Name=MyApp
GenericName=My app
Comment=Application to do something
Exec=bash -c "sleep 7 && myapp"
Terminal=false
Type=Application
Icon=myapp
Categories=GNOME;GTK;Utility

After you do this, logout, and on relogin the application should autostart with the delay you indicated in its startup desktop file.

You might like: How To Use A Different GTK 3 Theme For Specific Applications