15

I have created a .desktop file in /etc/xdg/autostart which runs the command

Exec= disper -d LVDS,VGA-0 -r auto -e -t right

Now I want to add a second command to run after the first command. How do I do this ?

Eikonikos Eikon
  • 621
  • 2
  • 7
  • 9

3 Answers3

21

Apart from calling an external bash script there is this option:

Exec=sh -c "disper -d LVDS,VGA-0 -r auto -e -t right; echo Running other command; echo ...and an other one"
algol
  • 311
3

The easiest way is to wrap it all up in a script. For example:

#!/bin/bash

disper -d LVDS,VGA-0 -r auto -e -t right
second_command_here

Save it somewhere, such as ~/bin/my_wrapper_script.sh, and make it executable. Then change the Exec line of your .desktop file to point to it:

Exec=/home/my_username/my_wrapper_script.sh
2

According to this source:

The Exec key must contain a command line. A command line consists of an executable program optionally followed by one or more arguments.

My understanding of the above being that the Exec key supports a single command and that command can only contain 1 executable followed by arguments for the executable.

My tests to combine commands:

firefox && gedit
firefox & gedit
firefox ; gedit

resulted in the second executable being read as an argument which seems to confirm the text.

mango
  • 101