26

I need to launch some applications on KDE with some added config changes. The best way to do that without messing up with / is by copying .desktop file of individual applications, that I need to change config of, from /usr/share/applications, add options, and then copy them to ~/.local/share/applications.

I was wondering if that is going to cause any problems that I am not aware of. And if there is a better way to do that say by not copying everything but only adding a changes in the desktop file in ~/.local/share/applications.

Thanks.

1
  • 1
    Nono! only the specific ones!! Apr 17, 2015 at 16:07

2 Answers 2

22

Yes it should work to copy the ones you want to modify to ~/.local/share/applications, and shouldn't cause too many problems unless you make some bad edits (e.g. removing mime-types etc). Copying all the ones mean that if they are updated at /usr/share/applications, they won;t be updated in ~/.local/share/applications, and the launchers for apps you remove will remain. Don't bother copying all of them that is unnecessary.

After you make the edits, running update-desktop-database ~/.local/share/applications/ should make sure the new launcher is recognised, so is shown in the Dash/Menu.

Unity's launcher, and probably Gnome's Dash will likely still show the version in /usr/share/applications, so you will need to unlock and lock the icon. Gnome 3 may also need a restart, Nautilus may do as well so logging out and logging back in should fix this.

Reading the following may help with making edits:

7
  • I wonder in what case would I see dulicate entry for an app that have a desktop file in both /usr/share/applications and ~/.local/share/applications. Apr 17, 2015 at 18:56
  • @donniezazen see: askubuntu.com/a/516346/72216 Apr 17, 2015 at 19:04
  • 1
    @JacobVlijm I see if the filenames are same then the one in ~/.local/share/applications takes precedence. Thanks. Apr 17, 2015 at 19:15
  • @donniezazen something to keep in mind with locally edited .desktop files is that they are not updated if an application is updated (including the global .desktop file), but not the local one. Chrome is famous for that, resulting in duplicate icons. Apr 17, 2015 at 20:14
  • In Ubuntu 18.10, if I copy the Terminal entry org.gnome.Terminal.desktop, then when it opens the modified .desktop from super + search as desired, but the icon shown on the dock for this new modified terminal window still refers to the system .desktop. Mar 31, 2019 at 12:57
3

Don't copy all files/directories from /usr/share/applications

It is indeed good practice to copy a .desktop file locally before editing it. That is the appropriate procedure. After you copied/edited it and logged out/in, the local one will overrule the global one.

Not all files in /usr/share/applications are meant to be run by the user directly however. Some files possibly are no .desktop files at all and even a few directories may exist. That is (a.o.) why you should not simply copy everything from /usr/share/applications into ~/.local/share/applications.

There is also no reason at all to copy all .desktop files locally. The local ones will only overrule the global ones if the local one exists. If the local one does not exist, the global one still is "in charge".

Is there a risk if I copy the complete contents of /usr/share/applications to ~/.local/share/applications?

Apart from creating useless duplicates, copying everything from /usr/share/applications can cause conflicts starting up your desktop. I actually did that once as an experiment (Unity), had to fix things with a startup usb.

Conclusion:

Only copy global .desktop files to ~/.local/share/applications if you have a reason to do that, and only copy (and edit) files specifically.

If you mess up a .desktop file somehow, the application won't startup from Dash or you are experiencing duplicate icons in Dash, if you do not manage to fix, simply remove the local .desktop, log out/in and things are as they were before.

4
  • Thanks for the write up. Just to let you know I should have been clearer I have no intention of copying the whole directory. I only meant to copy individual files. Apr 17, 2015 at 18:46
  • 2
    @donniezazen Ah, then it should be fine. In most cases, if you really mess up a .desktop file, simply remove it log, out/in and things are as they were before. Apr 17, 2015 at 18:49
  • 1
    Also do not hesitate to remove all .desktop from ~/.local/share/applications if you start to see strange behavior with your applications, browser starting strangely, multiples icons of the same app in the launcher, etc.
    – Natim
    Dec 22, 2016 at 9:03
  • 1
    For Ubuntu 20.04, 'desktop files in ~/.local/share/applications with the same name did not override files sourced from /usr/share/applications/, even after update-desktop-database ~/.local/share/applications/. XDG_DATA_HOME when unset should default/apply ~/.local/share/applications to supercede XDG_DATA_DIRS dir locations like /usr/share/applications/. But I observed the opposite. E.g. /usr/share/applications/firefox.desktop was favored and my ~/.local/share/applications/firefox.desktop customization failed to apply.
    – JPvRiel
    May 11, 2021 at 19:14

You must log in to answer this question.

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