5

I created a desktop shortcut to launch Android Studio - studio.desktop. But I just can't get it to run. Ubuntu 22.04 keeps popping up a dialog Untrusted Desktop File

This .desktop file is not trusted, it can not be launched. To enable launching, right-click, then:
**Enable "Allow Launching"**

But this dialog has only "Close" button. And on the Destop, wherever I right-click, I don't see any "Allow Launching". Okay, I thought - try to do this by terminal.

I have already tried a whole mountain of commands, but they do not help.

chmod a+x studio.desktop // Just in case, although I previously did it through the Permissions of the shortcut itself

dbus-launch gio set studio.desktop "metadata::trusted" yes

That didn't show any message and launching is still not allowed. Then i try this:

sudo gio set studio.desktop metadata::trusted true

This return message "gio: Setting attribute metadata::trusted not supported"

I also tried:

sudo desktop-file-install studio.desktop

As you probably guessed, also to no avail.

This is my studio.desktop:

[Desktop Entry]
Comment=Run Android Studio link
Exec=bash -c /home/user/android-studio/bin/studio.sh
GenericName=Android Studio
Icon=/home/user/android-studio/bin/studio.png
Name=Android Studio
Type=Application
Terminal=false
Zanna
  • 72,312

6 Answers6

3

The following worked for me: go to your home directory in Nautilus, right-click the Desktop folder, go to Properties, then Permissions tab. In the permissions, remove any permission more than "Access files" from "Others". I.e. the bug in Ubuntu 22.04 happens when Others are given write permission.

Or run the following command in Terminal:

chmod -R 775 ~/Desktop
3

I struggled with this problem after upgrading to 22.04. The setups that worked in 20.04 stopped working as expected in 22.04. I am sharing my notes that helped me resolve this for my problem, in case it helps some one else.

  • If the .desktop file is for all users to use then it should be placed under /usr/local/share/applications.
  • If the .desktop file is only for the current user then it should be placed under ~/.local/share/applications.
  • The .desktop file placed as above does not need execute permissions. It can be 0644. That is to say stat --format="%a" myfile.desktop should display 644.
  • If the .desktop file has a key Hidden then it should be Hidden=false. If the key is not present in the file then it does not matter as the default for Hidden is false.
  • If the .desktop file has a key NoDisplay then it should be NoDisplay=false. If the key is not present in the file then it does not matter as the default for NoDisplay is false.
  • The Exec key should have a valid command. Bash commands may not work as detailed in this answer.

With these settings in place the desktop entry should be searchable using the Super key, which means that the file is recognized as launchable.

As always, pinning the desktop entry to the launch bar can be done by alternate click on the searched desktop entry to bring up the context menu, followed by clicking on Add to Favorites from the menu.

Dhwani Katagade
  • 383
  • 5
  • 11
1

Open a terminal and enter the command chmod +x /path/to/studio.desktop

1

I personally suffer lots about it. maybe some changes on ubuntu 22.04. then found some solutions on the internet. I also copy past .desktop file form "/usr/share/applications" that doesn't work for me.

Work for me:

  1. create ".desktop" file
  2. add your rules like: exec cmd, icon source etc
  3. mouse right-click and see one new option called "Allow Lunching"(click it)
  4. give permission "sudo chmod +x {your .desktop file name}"
  5. then yeee(enjoy it)

src: https://linuxconfig.org/how-to-create-desktop-shortcut-launcher-on-ubuntu-22-04-jammy-jellyfish-linux

anjanx44
  • 121
1

In my case (and I tried it yesterday) for some reason in Ubuntu I had to make sure that two lines find themselves inside .desktop file and then all of suddenly everything worked without playing with metacity. Also it immediately showed in GUI application 'StartUp Applications'

  1. I made sure that name of my desktop file (in posted question it was studio.desktop) matches the name in the line Name=studio.desktop
  2. Secondly once I added Hidden=false It all started to work without playing with 'metacity is trusted..' Just normal persmission 755 for my desktop file which was inside ~/.config/autostart in my case. In Linuxmint I never had to make identical the file name and line with 'Name=' inside .desktop file, but for some reason it seems to be now different with Ubuntu 22.04. I even noticed when I copied this file that Ubuntu automatically changed file name without asking anything and this is how I got the idea to make these two things identical. I repeated several times this on a freshly installed Ubuntu 22.04.2 and it worked everytime.
1

Press right-click on the app and then it shows up on ubuntu 22.04