lubuntu how to execute 2 commands in .desktop file?

15,044

Solution 1

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"

Solution 2

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

Solution 3

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.

Share:
15,044

Related videos on Youtube

Eikonikos Eikon
Author by

Eikonikos Eikon

lubuntu user

Updated on September 18, 2022

Comments

  • Eikonikos Eikon
    Eikonikos Eikon over 1 year

    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 ?

    • Louis Matthijssen
      Louis Matthijssen about 10 years
      Create a bash script, run multiple commands in it and run the bash script from your .desktop?
  • Tfb9
    Tfb9 over 7 years
    I am using this variation to remedy some conky issues: Exec=sh -c "gnome-terminal & killall -SIGUSR1 conky"
  • Brian Wiley
    Brian Wiley over 3 years
    can any of the commands set an environment variable such as LD_LIBRARY_PATH?