Changing .desktop file directory

I want to create .desktop file in /usr/local/share/applications directory. Right now i have a snapcraft.yaml file is like this:

apps:
  app_name:
    command: bin/app_name
    desktop: share/applications/app_name.desktop

If i changed to this:

apps:
    my-app:
        command: usr/local/bin/app_name
        desktop: usr/local/share/applications/app_name.desktop

Will .desktop file created under the directory that i want?

Specifying the desktop field like that isn’t for choosing where the .desktop file goes on the host, it’s for telling snap where to find the .desktop template in your snap, which it then uses to make the real .desktop file on the system. The location the generated host desktop file usually ends up is somewhere in /var/lib/snapd/, but for your users shouldn’t usually matter, because the snapd package should add this to the list of places that are searched by default so you can actually make menu entries and from their perspective it works like magic.

In general, you cannot modify arbitrary files on the host itself.

1 Like