How to set up desktop shortcuts in KDE to run terminal commands?

9,464

Solution 1

You don't need a script to do that, in a terminal just do

$ which spyder

This gives you the full path to the file that's executed, I suppose /usr/bin/spyder. Then just use that path for your Exec= line.

Exec=/usr/bin/spyder

Solution 2

To configure KDE desktop shortcut to run specific command, you have to link the full path of the application.

i.e. use Exec=/home/(user)/Desktop/spy.sh instead of Exec=/Desktop/spy.sh (Because if you type /Desktop/spy.sh the system will actually find files from / --> /Desktop, which this folder will probably never exist.)

And for runing Spyder, follow dessert's answer.

Also, make sure spy.sh is executable, or else Permission denied will appear.

Share:
9,464

Related videos on Youtube

Alekh Karkada Ashok
Author by

Alekh Karkada Ashok

Updated on September 18, 2022

Comments

  • Alekh Karkada Ashok
    Alekh Karkada Ashok over 1 year

    I am trying to make a desktop shortcut to launch Spyder, which can be launched by typing spyder in terminal.

    I made a spy.sh script with spyder in it. It works with bash spy.sh and ./spy.sh. But when I make a desktop shortcut like this:

    [Desktop Entry]
    Name=spyd
    Exec=/Desktop/spy.sh
    Comment=
    Icon=
    Type=Application
    Terminal=true
    

    It gives out an error:

    "There was an error creating child process for the terminal. Failed to execute child process “/Desktop/spy.sh” (No such file or directory)"

    Same error when I change into Exec=spyder

    What should I do?

  • Alekh Karkada Ashok
    Alekh Karkada Ashok over 6 years
    Thanks a lot. Even though linking full path helped remove the error, I couldn't run spyder successfully, a program would come up in taskbar called "web browser" and close. Following dessert's answer did the work.
  • Cynplytholowazy
    Cynplytholowazy over 6 years
    You probably have a corrupted spy.sh script. Also, if you find an answer working, mark the answer accepted by clicking the checkmark icon.
  • Alekh Karkada Ashok
    Alekh Karkada Ashok over 6 years
    But it works when executed from terminal. BTW, why doesn't just writing spyder in Exec= work for me? (suggested here - stackoverflow.com/questions/39771849/…)
  • Cynplytholowazy
    Cynplytholowazy over 6 years
    Because the desktop environment won't automatically search for spyder for you. If you type export you will see something like PATH=/usr/bin... but KDE desktop won't check this parameter.
  • Alekh Karkada Ashok
    Alekh Karkada Ashok over 6 years
    Oh, so this is KDE specific and we can not run commands without making a script? Thanks!
  • Cynplytholowazy
    Cynplytholowazy over 6 years
    Not really, most desktop environment won't do that as well.
  • dessert
    dessert over 6 years
    @AlekhKarkadaAshok I consider the automatic path completion a terminal feature, it's a good idea to give the full path everywhere else, especially in config files.