How to delay the startup application on Linux

This article describes how to delay the start of an application in two ways.

1. Use X-GNOME-Autostart-Delay to add startup delay to the application

Some desktop environments (such as GNOME) support the automatic startup parameter X-GNOME-Autostart-Delay, which is used to delay the startup of the application after logging in.

This applies to GNOME, Unity, MATE, Cinnamon and other desktop environments, but not all. For example, KDE and Xfce do not support this feature. Some of them already have a startup delay option in the startup application GUI, such as MATE or Cinnamon desktop:

Start delay cinnamon
Boot delay option on Cinnamon desktop (Linux Mint)

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

Find the auto-start desktop file in any one ~/.config/autostart For your users, or /etc/xdg/autostart For all users, please use a text editor (e.g. Nano) to open the file (e.g. nano ~/.config/autostart/<myapp>.desktop), and then add it to the file without any other modifications:

X-GNOME-Autostart-Delay=<xx>

where xx Is the startup delay you want to add to this application, in seconds.

The example I added to automatically start the desktop entry X-GNOME-Autostart-Delay Delay for 10 seconds:

[Desktop Entry]Name=MyAppGenericName=My appComment=Application to do somethingExec=myappTerminal=falseType=ApplicationIcon=myappCategories=GNOME;GTK;UtilityX-GNOME-Autostart-Delay=10

You might also like: KDE Connect / GSConnect: How to lock/unlock Linux desktop with Android device

2. Use the following command to add startup delay to some applications sleep

If your desktop environment does not support X-GNOME-Autostart-Delay Parameter, you can use a general method to delay the start of the application at startup.

To do this, look for the application/command autostart desktop file in any of the following locations ~/.config/autostart For your users, or /etc/xdg/autostart Applies to all users.You need to open the file with a text editor (if from /etc/xdg/autostart) Add start delay.

In this auto-start desktop file, modify Exec Values ​​like this: bash -c "sleep <xx> && <original_command>".where xx Is the number of seconds to add as the start delay for that time original_command.

The sample startup desktop file where I run the “MyApp” application with a 7-second startup delay:

[Desktop Entry]Name=MyAppGenericName=My appComment=Application to do somethingExec=bash -c "sleep 7 && myapp"Terminal=falseType=ApplicationIcon=myappCategories=GNOME;GTK;Utility

After doing this, after logging out and logging back in, the application should start automatically with the delay you indicated in its startup desktop file.

You might like: How to use different GTK 3 themes for specific applications

Source

Sidebar