Created .desktop launcher is not working in Ubuntu 19.04

5,460

Solution 1

Your desktop file should look something like this:

[Desktop Entry]
Version=1.0
Name=Todoist
Exec=bash -c 'cd ~/todoist-linux-1.17 && make up' 
Terminal=true
Type=Application
Categories=Application;

You can also set terminal=false and replace Exec=bash -c 'cd ~/todoist-linux-1.17 && make up' with Exec=gnome-terminal -e "bash -c 'cd ~/todoist-linux-1.17 && make up'" to run this in gnome terminal.

Solution 2

You need to create a bash script for the command you want to run and the point the Exec= entry to the script.

First create a simple script, i.e. a text file, say a file named myscript in your Documents folder with the following text

#!/bin/bash
cd ~/todoist-linux-1.17 && make up

and make it executable. Then modify your .desktop launcher and for the Exec entry use the following

Exec=/home/YOUR-USERNAME/Documents/myscript

(you need to use absolute paths in the .desktop file).

Share:
5,460

Related videos on Youtube

Viktor
Author by

Viktor

Updated on September 18, 2022

Comments

  • Viktor
    Viktor almost 2 years

    I wanted to create a shortcut to run a command which will move to a directory and run a command. The problem is that when double-click the launcher, it doesn't do anything. I set check "Allow execute as a programm". This is how my .desktop file looks like

    [Desktop Entry]
    Version=1.0
    Type=Application
    Terminal=true
    Exec=cd ~/todoist-linux-1.17 && make up 
    Name=Todoist
    Icon= 
    

    enter image description here

  • Viktor
    Viktor almost 5 years
    still, it doesn't run, I included a screenshot of how this shortcut looks like, maybe it is being run with the incorrect application?
  • pomsky
    pomsky almost 5 years
    @Viktor You haven't mentioned in the question, but now from the screenshot it looks like you have placed the .desktop file in your Desktop. On Ubuntu 19.04, Nautilus (file-manager) does not handle desktop icons, they're provided by a GNOME extension. Currently the extension provides only a limited number of features. Place the .desktop file in some other folder and try. If it works, put the .desktop file in your ~/.local/share/applications/ folder. Then you would be able to search and launch it from the 'Activities' overview or 'Show Applications' screen.
  • Viktor
    Viktor almost 5 years
    Thank you for your help, now it has a preloader but it doesn't execute the script, if i did everything correctly, i created todoist.sh script inside Document put the .desktop file in the same place and put the full path to script Exec=/home/viktor/Documents/todoist as well tried with todoist.sh
  • pomsky
    pomsky almost 5 years
    Does just running the command in Terminal work? Not sure what's specific about this command, I tried with some generic and basic commands, it works okay.
  • Viktor
    Viktor almost 5 years
    yes i runned the command separetly and it worked
  • pomsky
    pomsky almost 5 years
    Not sure what's going wrong here, sorry :( Just to make sure, is your system language English?
  • vanadium
    vanadium almost 5 years
    I consider the answer of Synchro as the simplest and more straighforward approach here, but unfortunatelly there are other issues with that anwer.
  • Viktor
    Viktor almost 5 years
    i noticed that launcher is not working at all no matter what kind of command i put