1

I've got a script file in my home directory that I've added to Startup Applications. It then creates a .desktop file in ~/.config/autostart. Is it possible to just cut out the middle man, and run this script directly from the autostart folder?

The structure of the script is along the lines of:

command1
command2
command3

I tried making it one line by rearranging the script to read:

command1;command2;command3

The idea behind this was to swap out the following line in the .desktop file from this:

Exec=/home/hiigaran/startupfile

To this:

Exec=command1;command2;command3

This doesn't seem to work. I'm guessing multiple commands aren't supported. Is there any other way?

To be clear, I don't have any particular problem with the current way I'm doing things. Everything functions as it should. I'm just very particular about my home directory contents. If there is a more elegant way to run my script after logging in to the desktop, great. If not, no big deal.

To my understanding, KDE has a ~/.config/autostart-scripts directory that would work perfectly for me. This seems to be a folder found only in KDE however. I'm using the default DE for Ubuntu 18.04.

1
4

Instead of Exec=command1;command2;command3 try

Exec=sh -c "command1;command2;command3"
1
  • Initially, this one didn't work, but @N0rbert's link mentioned that I needed to escape some characters first. Works as intended now. Thank you. – hiigaran Sep 2 '18 at 12:34
0

I would strongly advise against this sort of thing as you end up forgetting why you jumped through hoops you didn't need to.

Simply create a shell script containing your multiple commands and stick that in whatever local "bin" you use (typically ~/bin) chmod 755 it and reference THAT in your .desktop file.

It will, of course, be properly laid out, commented and maybe even be in your bin git repo ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.