1

I've come across a number of apps that need to be launched by executing a .desktop file. I understand that Canonical have disabled running these kinds of apps for security reasons. How does one accept the risk and allow these apps to run?

Using the terminal and typing [./MyApp.desktop] works and successfully launches the app but that's not an ideal solution for apps that are run often and it leaves an unnecessary terminal window open. How does one launch a .desktop app by simply double clicking on it in Ubuntu?

Suggestions I've come across that do not work:

  1. Checking the "Allow executing file as a program" box in properties.
  2. Setting the "Open with..." app to "Run Software".
2
  • Place a valid .desktop file into ~/.local/share/applications, and then use the standard "Windows" key launcher to start the app as normal.
    – heynnema
    Mar 22, 2022 at 20:01
  • 1
    Does this answer your question? How can I create launchers on my desktop?
    – karel
    Sep 24 at 17:09

3 Answers 3

1

This worked for me running Ubuntu 22.04.3:

  1. Put someApp.desktop file in /usr/share/applications folder

    sudo cp /path/to/someApp.desktop /usr/share/applications
    
  2. Change file permission

    sudo chmod +wr /usr/share/application/someApp.desktop
    
  3. Then you can search the app in "Show applications" panel, as if it was installed from the app store.

New contributor
Jingyu Lei is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
0

I did not know that starting your app by launching the .desktop file is possible, nor does it work on my side.

Here's what I learned when having the same issue:

  • Your file needs to be placed in the directory /usr/share/applications if it needs to be available for all users
  • Your file needs to be placed in the directory ${HOME}/Desktop if it should be available only to the current user
  • The contents of the file must be exactly correct (I used to have [Desktop entry] as the section header but it needed to be [Desktop Entry] with a capital E)
  • You also need to check "Allow executing file as a program" (as you wrote...)
  • I am not sure if you really have to specify a value for "Open with..." (Maybe it is not needed, though I specified "Run Software" as well.)
  • After saving the .desktop file, an icon should appear on the desktop.
  • Right-click that icon. In the context menu which is shown, click "Allow Launching".
  • The icon should change to the application's icon (if one is specified in the .desktop file) and the application should launch after double-clicking the shortcut icon.

Here's an example .desktop file:

[Desktop Entry]
Name=MyApp
Comment=MyApp is my favourite app for everything
Exec=/usr/local/myApp/myApp.sh
Icon=/usr/local/myApp/myApp-icon.png
Type=Application

There's also a way to check the .desktop file for validity:

$ desktop-file-validate myApp.desktop

If there's no output and the return value of the check is 0 (check with echo $?, the shortcut should be fine. If there's an output, it should indicate what's wrong with the file. The return value should be different from 0 (e.g. 1, also use echo $? to check)

4
  • Thanks for the attempt but "Allow Launching" doesn't show up (in Ubuntu) and the icon isn't showing. Double clicking does nothing as expected. Seems like Ubuntu has just outright blocked support for the .desktop standard. At least terminal still works. Mar 26, 2022 at 6:22
  • did you check the file using desktop-file-validate?
    – TomS
    Mar 27, 2022 at 13:17
  • I did validate it Apr 22, 2022 at 7:04
  • Ok, did you also select "Allow launching" from the context menu of the desktop shortcut?
    – TomS
    Apr 22, 2022 at 13:57
0

Ubuntu 22.04

The ideas presented as answers also apply to Ubuntu 22.04. Here is a test:

copy a desktop file from ~/.local/share/applications to ~/Desktop, then

double-click the .desktop file and Ubuntu 22.04 replies

Invalid Permissions on Desktop File

Also displayed is

Enable option, Allow Executing File as a Program

the option located under

Permissions from Properties (right click menu).

Following that advice works. The right-click menu also has toggle Allow Launching which suffices to run the .desktop file. The Allow Launching toggle also sets Permissions in Properties.

The simplest answer to the question is then: right-click on the .desktop file and select Allow Launching. The icon for the .desktop file changes and double-click launches the .desktop file. To toggle launching, right-click and select Don't Allow Launching.

1
  • 2
    Right, but this isn't answering the OPs question.
    – pgoetz
    Feb 23 at 20:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .