4

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
  • 70,465
  • 2
    Enter the command chmod +x /path/to/studio.desktop – Archisman Panigrahi May 13 '22 at 17:39
  • Watch the system logs with the terminal command sudo journalctl --follow as you try. Paste your script into https://shellcheck.net, a syntax checker, or install shellcheck locally. Make using shellcheck part of your development process. Does /home/user/android-studio/bin/studio.sh use environments that are set up for your desktop, but not set up for desktop files? – waltinator May 13 '22 at 17:48
  • What filesystem is /home/user/android-studio/bin/studio.sh on? Is it mounted with noexec? Explore your Mount/Read/Write/Execute problems with https://github.com/waltinator/pathlld, a bash script to show the permissions, mount options along the path to an object or objects. – waltinator May 13 '22 at 17:55
  • Shellcheck shows only these errors:

    Line 1: Laptop dbus-daemon[1881]: [session uid=1000 pid=1881] Successfully activated service 'org.gnome.ArchiveManager1' ^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.

    And for next lines: Line 2: Laptop gnome-shell[1991]: DING: Detected async api for thumbnails Line 3: Laptop gnome-shell[1991]: DING: desktop-icons: Desktop is writable by others - will not allow launching any desktop files

    Show same error: SC2102 (info): Ranges can only match single chars (mentioned due to duplicates).

    – Никитос May 15 '22 at 14:04

5 Answers5

1

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
1

I struggled with this problem after upgrading to 22.04. The setups that worked in 20.04 stopped working in 22.04 as expected. 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.
  • If the .desktop file has a key Hidden then it should be Hidden=false.
  • If the .desktop file has a key NoDisplay then it should be NoDisplay=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 if is recognized as launchable.

0

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

Archisman Panigrahi
  • 28,338
  • 18
  • 105
  • 212
0

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
  • 111
  • 5
  • It is not clear what you mean by step #2, "Add your rules like:" Please elaborate as to what "add your rules like:" means. Also, step #5 is ambiguous; "yeee" is not an English word. Have you misspelled something or have you failed to finish a thought? – MDeBusk Sep 28 '22 at 02:50
  • step2; rules mean cmds [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 – anjanx44 Sep 28 '22 at 10:01
  • @MDeBusk can you see src link? – anjanx44 Sep 28 '22 at 10:04
  • 1
    I'm just wondering, doesn't anyone find it a little, khhm... "strange" that it takes a whole guide to create a shortcut? – Никитос Aug 04 '23 at 02:10
  • @Никитос Gnome Shell desktop was designed to have no desktop icons. It would be silly to have a default option to create a desktop shortcut when desktop icons literally do not exist. The ability to add desktop icons was enabled by a third party Gnome Shell extension after the fact, which didn't include an additional function to easily create a desktop launcher. So someone either needs to write a Gnome Shell extension to provide this capability or we'll have to continue using this method. – mchid Sep 08 '23 at 07:04
0

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.