Edit: While the below is still potentially useful, at least as an example of setting a directory watch with systemd
, I’ve done additional testing on my part and found that the issue for me has specifically been that if I edit a file using nano
, that the cache update is not triggered due to how nano saves files, however using something else like vim
or Kate
which create/delete temporary files (for me at least) as part of saving does cause the cache update to trigger.
You can try running kbuildsycoca5
. As per the man page it “Rebuilds the KService desktop file system configuration cache”.
I don’t know that there’s a watch on the directories for changes, I think it may be that when you install applications that the cache update is triggered (someone more knowledgeable may be able to better inform on this).
The recommendation to put modified .desktop
files in ~/.local/share/applications/
I think is a good idea in general since the local .desktop
file will override the system one (as long as the .desktop
files are named the same), though changes in the local directory don’t seem to get picked up unless the cache is rebuilt (or at least it doesn’t for me).
To that end, for the .desktop
files in the home directory, I actually ended up using systemd to watch the path which triggers the kbuildsycoca5
command to run.
To do this, under ~/.config/systemd/user/
create two files:
rebuild-kservice-cache.path
(change the [USERHOMEHERE] portion to your home directory):
[Unit]
Description="Monitor ~/.local/share/applications/"
[Path]
PathModified=/home/[USERHOMEHERE]/.local/share/applications
TriggerLimitIntervalSec=5s
TriggerLimitBurst=1
Unit=rebuild-kservice-cache.service
[Install]
WantedBy=default.target
rebuild-kservice-cache.service
:
[Unit]
Description="Rebuild the KService desktop file system configuration cache when ~/.local/share/applications/ changes"
[Service]
ExecStart=kbuildsycoca5
Then reload the user systemd manager configuration via:
systemctl --user daemon-reload
And finally enable and start the rebuild-kservice-cache.path
:
systemctl --user enable --now rebuild-kservice-cache.path
In theory, you could also change the above path to the home applications folder to watch the /var/lib/flatpak/exports/share/applications/
directory instead, but I’d recommend trying to copy the .desktop
file to the relevant home directory first, that way you shouldn’t have an issue if an update changes the system shortcut.