Add an autostart application for all users

To start an application automatically when the user logs in, you need to create a .desktop file for that application in the /etc/xdg/autostart/ directory.

To add an autostart application for all users:

  1. Create a .desktop file in the /etc/xdg/autostart/ directory:

    [Desktop Entry]
    Type=Application
    Name=Files
    Exec=nautilus -n
    OnlyShowIn=GNOME;
    AutostartCondition=GSettings org.gnome.desktop.background show-desktop-icons
  2. Replace Files with the name of the application.

  3. Replace nautilus -n with the command you wish to use to run the application.

  4. You can use the AutostartCondition key to check for a value of a GSettings key.

    The session manager runs the application automatically if the key's value is true. If the key's value changes in the running session, the session manager starts or stops the application, depending on what the previous value for the key was.