Uninstalling a desktop file

If you rename or delete a .desktop file, you might want to "uninstall" the old file, i.e. to overwrite it at install time with a file that says "deleted", in order to provide a smoother migration for people installing from sources.

The first step is to add a file called uninstall.desktop to your sources. It can be shared among subdirectories if needed. It should contain the following lines:

[Desktop Entry]
Encoding=UTF-8
Hidden=true

Now you should edit Makefile.am and add:

install-data-local: uninstall.desktop
$(mkinstalldirs) $(DESTDIR)/$(kde_datadir)/kmyapp
$(INSTALL_DATA) $(srcdir)/uninstall.desktop $(DESTDIR)
$(kde_datadir)/kmyapp/oldfilename.desktop

where $(kde_datadir)/kmyapp is just an example, it should be replaced with the directory where the .desktop was installed to. Don't forget to prepend $(DESTDIR).