9

In Windows, it's possible to make files open at startup (using the default program for opening the file) by adding the files to the startup folder. However, in Ubuntu, it isn't possible to drag a file onto the list of startup applications so that it runs at startup. Is there another way to make a file open at startup, using the default program for opening that file?

3 Answers 3

10

I assume that you use Unity, however the process is quite similar with other Desktop Environments aswell.

Open the Dash and search for:

startup application

Click add and specify the command you'd like to use. You can then use two approaches, either you open the file by selecting the application you'd like to start with the file as an parameter, or you can use xdg-open as mentioned in this askubuntu-thread:

xdg-open [/path/]filename
2
  • 1
    It should be possible to "drag and drop" a file onto the startup applications list in order to do this, but this feature hasn't been implemented yet. Where should this bug/feature request be filed? Jun 27, 2012 at 19:53
  • brainstorm.ubuntu.com is a good place to start! :-)
    – simme
    Jun 28, 2012 at 7:53
8

You may drag files to be executed at startup into ~/.config/autostart
However, they must be shortcuts (*.desktop files)
If you want to start scripts or documents,
put them in subfolders scripts and documents that you create inside autostart
and create the following shortcuts in autostart:

scripts.desktop:

[Desktop Entry]
Name=Scripts in 'scripts' folder
Exec=/bin/bash -c 'for f in ~/.config/autostart/scripts/*; do eval "$f&"; done'
Type=Application


documents.desktop:

[Desktop Entry]
Name=Documents in 'documents' folder
Exec=/bin/bash -c 'for f in ~/.config/autostart/documents/*; do eval "xdg-open $f&"; done'
Type=Application

Ubuntu ought to be bright enough to allow any .desktop, script, executable or document file to be put in autostart and execute it appropriately.

2
  • nice suggestion, but i am getting this error /bin/bash: eval: line 0: syntax error near unexpected token &' `
    – eadmaster
    Dec 2, 2017 at 13:53
  • how do the .desktop items relate to / conflict with / overlap / override / etc. the items in the Dash / Startup Applications GUI? I see some commonalities, but it's by no means one-to-one.
    – Reb.Cabin
    May 13, 2019 at 17:57
1

To open a file at startup using the default application, add this terminal command to the list of startup applications:

xdg-open (file path, without parentheses)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .