Every time the package is updated, it creates two .desktop icons. How to permanently remove them?
I have tried adding NoDisplay=true in the files so they disappear from the App Menu like I do with other packages, but Syncthing doesn’t work.
I also looked in the /var/lib/dpkg/info/syncthing.* files and especially the syncthing.postinst file but there are no options to prevent the icons from being recreated if removed from /usr/share/applications/ after upgrade.
Can I add specific lines in this file or is there any other way to prevent it besides manually removing them every time the package gets a new update?
The problem you’re having isn’t specific to Syncthing’s packaging. There are quite a few desktop environments for Linux that follow the XDG guidelines, so how .desktop files are handled depends a lot on the particular Linux distro and the choice of DE.
If NoDisplay=true isn’t working, given the available info, best guess is that you’ve got a syncthing-start.desktop and/or syncthing-ui.desktop elsewhere in addition to /usr/share/applications/.
/usr/share/applications is managed by the OS, so any local changes will potentially conflict with or be undone by future package installations and updates. APT is just doing exactly what it’s supposed to do when unpacking and installing a package.
If you’d like local custom .desktop files to apply to every user, drop them into /usr/local/share/applications/.
Otherwise, if they should only apply to your login’s menus, use .local/share/applications/.
Per-user settings override local system settings, which in turn override the default package settings.
All of my current Debian systems are either on 12/Bookworm or older than 11, so I installed 11 with the default GNOME to see if GNOME Shell was working as expected with .desktop files.
After adding apt.syncthing.net and installing the latest Syncthing, I wasn’t able to find any issues with NoDisplay=true. It worked as expected when I modified one or both of Syncthing’s .desktop files under /usr/share/applications/.
NoDisplay=true also worked perfectly when leaving Syncthing’s packaged .desktop files alone and overriding them with personal versions under ~/.local/share/applications/.
I primarily use Fedora Linux, and also verified that I could override the shortcuts.
So, the only reason that I can think of for what you’re describing is that there are another pair of syncthing-start.desktop and syncthing-ui.desktop on your system. If you haven’t already, do a full system search.
On a related note, maybe it’s just a difference in terminology, but GNOME Shell doesn’t have an “App Menu”, so are you using some kind of special menu applet? I ask because it seems unusual to hide apps from GNOME Shell’s app picker since it only list apps that you search for.
I really don’t know what’s happening, now it worked!
I didn’t updated to latest until I got the first reply so I can investigate. I now added the NoDisplay=true and it worked, but I clearly remember something regarding this not working.
Maybe my problem was with the .desktop icons coming back after an update, even though there was a NoDisplay=true line in there?!
For now I just hidden the icons with NoDisplay, which I thought it would not work but now it did!
I start to think that my problem was not that it would not hide, but rather that the icons would come back after an update, even if the NoDisplay is in place. It’s been a while since I last updated the package for the issue to come again, and I just created the thread just before I updated Syncthing so I could know what I can possibly do before messing something up.
Maybe each update overwrites theses files when they are in /usr/share/applications/? Will have to wait for the next update to see, I never had such problems with other packages. I would append NoDisplay after the initial install and they would never bother me again.
If a package contains .desktop files with the same filenames but newer timestamps, they’ll replace older ones under /usr/share/applications/, so some apps might go for months or years without a change.
It’s generally best to never modify /usr/share/applications/ which is managed by the package manager (e.g. APT, DNF).
For your custom .desktop files to always have the final say over whether or not an icon appears in your app menus, put them in your personal directory (~/.local/share/applications/) that only applies to your login.
Copy and modify – or even better – create from scratch.
Because all you want is to hide the shortcuts/icons, the other parameters in the .desktop file are just wasted bits of storage. Two lines will do it:
[Desktop Entry]
NoDisplay=true
You could even go hog wild and put the two lines above in a single reusable .desktop file with symlinks for every shortcut you ever want to hide, e.g.:
(Simply refer to /usr/share/applications/ for the required matching filename of each symlink.)
Although you could move them from /usr/share/applications/, consider that…
It’s best to avoid customizing /usr/share/applications/ because it’s the package manager’s domain, so local changes will be overwritten by package updates.
It’d remove the Syncthing shortcuts for other users (might not matter if you’re the only user, but it’s still bad practice nonetheless).
Keeping the changes in your user home simplifies backups, restores and upgrades (it’s way more portable than /usr/share/applications/).
Personalizing the look/feel of a non-root user environment should never require root privileges. If some document, webpage or video tutorial says otherwise, it’s most often not the right way.