Local .desktop files do not override global .desktop files

I have recently acquired a new monitor which supports high-dpi.
I have found myself in the necessity to launch some programs with a mix of environment variable to persuade them to use scaling.
Doing so I noticed that when I edit a .desktop file (not directly, but by choosing “Edit application…” in the launcher) all my edits are lost if I close and reopen the properties of that application.
I think I’ve seen this in the past, but it was usually a matter of refreshing the cache (kbuildsycoca5 or 6) or just rebooting.
Now the problem is much worse, as my KDE (on both my desktop and my laptop) is completely ignoring any .desktop file in ~/.local/share/applications, preferring instead those that are in /usr/share/applications.
No amount of cache refreshing or rebooting fixed this problem.

I opened a bug in the KDE bug tracker, but they ultimately told me that the problem is in openSUSE and that nobody else reported this besides me.

I have found several reports, but mostly in the past. I suspect people have given up on this feature and found their way to work-around the problem, or simply the problem was not bad enough for them to care.
That was my stance, too, until I got this new monitor.

One thing that bothers me is that the KDE developers pointed out a couple of XDG* environment variables that should be set in a certain way according to the freedesktop standard, but that are not apparently correctly set in openSUSE (at least in Tumbleweed).
However, even after manually fixing the environment variable, the problem still remains.

Is there anyone besides me experiencing this problem?
If so, please help me fix it or bring it to the attention of KDE developers.

Thank you in advance
Cris

1 Like

Not seeing any of this behavior here.

Thank you @sfalken .

Could you please paste here the value of your XDG_DATA_DIRS and XDG_DATA_HOME environment variables?

[sfalken@ranger ~]$ echo $XDG_DATA_DIRS
/home/sfalken/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share
[sfalken@ranger ~]$ echo $XDG_DATA_HOME

[sfalken@ranger ~]$ 

Hmmm…FWIW I did find some similar threads across different distros. Here’s a Fedora reddit thread describing similar. This part caught my attention, relating to updating the database…

1. Copy the desired desktop-file from /usr/share/applications/ to $HOME/.local/share/applications/ and keep the EXACT SAME FILENAME FOR THE DESKTOP FILE.

2. Then edit your own local one to do your tweaks.

3. Run the following command to register mime-type handlers (automatic file opening handlers): update-desktop-database ~/.local/share/applications --verbose

4. Then just wait or reboot. The application will now only use your local file and won't use the global desktop file at all anymore.

Like Shawn reported, I’m also not seeing any problem with respect to the menu editor. If I make a change, I’m prompted to save the change(s), and the the system configuration is updated accordingly.

Thank you once more @sfalken .
You environment variables look exactly like mine in two different Tumbleweed installations.
However, Nate Graham from KDE says that this setup is incorrect.
Please look at the bug to see the details if you’re interested.
Since your KDE is working correctly I guess Nate is wrong, BTW.

I’ve seen other distro topics discussing similar and the configured $XDG_DATA_DIRS directories are the same, so not related to the issue you are having.

I’ve only used command-line arguments in my cases, no environment variables, and only via the technique detailed in post 5, copying the ‘.desktop’ file to ‘.local/share/applications’ and tweaking the ‘exec’ line, and even though I have the same $XDG_DATA_DIRS as post 4, my custom launchers are honoured just fine - I didn’t even know there was an ‘Edit Application…’ tool until I saw this thread.

One question leapt to mind when I read your bug-report, however; Are you using Plasma-X11 or Plasma-Wayland, or do you switch between them? I’m wondering if some of those variables might be unique to one environment over the other…?

In the past days I’ve done a big cleanup of the .desktop files in ~/.local/share/applications. It’s incredible how much rubbish gets accumulated there!

There were .desktop files from programs I uninstalled in 2021!

After cleaning up the rubbish, I checked all the remaining .desktop file with desktop-file-validate, and I corrected some of them, to the point were I had only a few warnings.

I then ran kbuildsycoca6 --noincremental to completely rebuild the cache, and then I also rebooted just to be on the safe side.

Unfortunately none of this helped… I am still experiencing the problem where none of the updated .desktop files in ~/.local/share/applications overrides their corresponding file in /usr/share/applications.

I also tested all the manual methods suggested here or in other threads (e.g. using desktop-file-install, desktop-file-edit, update-desktop-database, etc.) without any difference in results.

Just to test if KDE was at all looking at the ~/.local/share/applications directory, I duplicated one of the .desktop files changing its name.
Immediately, I had a new start menu entry were I could see the updated environment variables.

I am out of ideas on how to debug this weird situation.

I even tried to debug plasmashell by using
sudo strace -e trace=openat -f -p <plasmashell-pid> 2>&1 | tee ~/plasma-strace.log

I still have to test more thoroughly, but my first try showed that the .desktop file in ~/.local/share/applications was opened!!

Any help or idea is accepted, thank you in advance.
Just don’t suggest to reinstall please: I have two computers that exhibit the same behavior, and I also tried with a brand new user on this system and it had the same behavior, too.

Best
Cris

Please show us the results from
ls -la ~/.local/share/applications

What happens if you remove the cache with

rm ~/.cache/ksycoca*

then access the application menu again?

Here it is:

totale 464
drwxr-xr-x   3 cris users  8192 22 apr 09.39 .
drwxr-xr-x 194 cris users  8192 22 apr 12.16 ..
-rw-------   1 cris users   415 22 mar  2019 4K SlideShow Maker.desktop
-rw-------   1 cris users   396 30 dic  2023 Apache Directory Studio.desktop
-rw-r--r--   1 cris users  1958 22 apr 09.39 appimagekit_14f0acf0b38dd213da3f264d11a31dd0.desktop
-rw-r--r--   1 cris users  2705 22 apr 09.39 appimagekit_21909baaed0c7e623e4beba9cfc47bff.desktop
-rw-r--r--   1 cris users  1732 22 apr 09.39 appimagekit_34673296035227e986c134089286d81b.desktop
-rw-r--r--   1 cris users  1678 22 apr 09.39 appimagekit_49f3772031c953a7157edeae43947d27.desktop
-rw-r--r--   1 cris users  1936 22 apr 09.39 appimagekit_611c68270c3b16c422f5b786297d3882.desktop
-rw-r--r--   1 cris users  2305 22 apr 09.39 appimagekit_7401497712fc95dae0d4b668dd38048e.desktop
-rw-r--r--   1 cris users  2068 22 apr 09.39 appimagekit_79eb537e3ba5261d611996237f6e0cac.desktop
-rw-r--r--   1 cris users  1576 22 apr 09.39 appimagekit_8e152afc0656affbf6f9cfc14299e3b5.desktop
-rw-r--r--   1 cris users  1738 22 apr 09.39 appimagekit_94b3b7710c85c6f819fff8d7b784468d.desktop
-rw-r--r--   1 cris users  1552 22 apr 09.39 appimagekit_c448c5b2a0ee5ad9a4d987339e3ae09f.desktop
-rw-r--r--   1 cris users  5334 22 apr 09.39 appimagekit_c71adb554067fa3b6347fd88090b8411.desktop
-rw-r--r--   1 cris users  1883 22 apr 09.39 appimagekit_c7c3651fc4a7874e02a14025cdaf2e03.desktop
-rw-r--r--   1 cris users  1398 22 apr 09.39 appimagekit_d66bf0f57c74baa4a81a43835fe2d300.desktop
-rw-r--r--   1 cris users  1627 22 apr 09.39 appimagekit_dc4ea63e3c2ded654147b8bc27b4e22c.desktop
-rw-r--r--   1 cris users  1663 22 apr 09.39 appimagekit_e44fa31874404a3ee282b189f9ab330b.desktop
-rw-r--r--   1 cris users  1416 22 apr 09.39 appimagekit_ea07c4c95d28ef7922316be26ce833ab.desktop
-rw-r--r--   1 cris users  1607 22 apr 09.39 appimagekit_f64d6e4a42ad0c0a5571b234e19ea90f.desktop
-rw-r--r--   1 cris users  1606 22 apr 09.39 appimagekit_f72da9354da4d2659648e695c767ae3d.desktop
-rw-------   1 cris users   768  5 set  2024 app.rednotebook.RedNotebook.desktop
-rw-r--r--   1 cris users   326  6 nov 11.33 ArubaSign.desktop
-rw-r--r--   1 cris users   532 14 dic 00.40 AssoInvoice.desktop
-rw-------   1 cris users   349 22 ott  2018 blockOut.desktop
-rw-------   1 cris users   412 13 dic 10.47 chrome-kjgfgldnnfoeklkmfkjfagphfepbbdan-Default.desktop
-rw-r--r--   1 cris users   508 19 apr 00.51 dbeaver-ce.desktop
-rw-------   1 cris users   277 18 feb 19.55 ddcui.desktop
-rw-------   1 cris users   698 19 apr 15.09 defaults.list
-rw-r--r--   1 cris users   450  4 ott  2024 FFPWA-01J9BNYE6XNH737WD3FT38TCM3.desktop
-rw-r--r--   1 cris users   504 18 ott  2024 FFPWA-01JA55XASJ5XZ5WX44T5CFP9TH.desktop
-rw-r--r--   1 cris users   310 19 apr 14.36 FFPWA-01JACYYTGJTYB8VJVWSEYDM9Y9.desktop
-rw-r--r--   1 cris users   422 26 feb 00.39 FFPWA-01JMZQKX9S1WM7T43BBEQ5XHDM.desktop
-rw-r--r--   1 cris users   503  7 apr 15.25 FFPWA-01JR86SZTWXBWQK5G1DV93PGNV.desktop
-rw-------   1 cris users   308 19 apr 13.00 FoxitReader.desktop
-rw-r--r--   1 cris users   220 19 apr 01.17 gambas-example-DBusExplorer.desktop
-rwx------   1 cris users   325 18 feb 17.40 helpwire-operator.desktop
-rwx------   1 cris users   492 29 dic 21.52 install4j_yegx8t-pdfstudio2024.desktop
-rwx------   1 cris users   221 30 gen 13.05 install4j_zl8g0d-yEd.desktop
-rw-------   1 cris users   309 18 feb 19.34 JBidWatcher.desktop
-rwxr--r--   1 cris users   427 18 apr 13.21 jetbrains-idea-ce.desktop
-rwxr--r--   1 cris users   376 18 apr 13.22 jetbrains-pycharm-2f044119-e71e-4e27-bf8d-8c82a850f3ad.desktop
-rw-r--r--   1 cris users   438 27 set  2022 jetbrains-toolbox.desktop
-rw-r--r--   1 cris users   373 19 apr 14.41 kdocker.desktop
-rw-------   1 cris users   297 10 mar 21.54 Krokiet.desktop
-rw-------   1 cris users   803 20 dic 11.47 libreoffice-base.desktop
-rw-------   1 cris users  2143 20 dic 11.47 libreoffice-calc.desktop
-rw-------   1 cris users  1342 20 dic 11.47 libreoffice-draw.desktop
-rw-------   1 cris users  1705 20 dic 11.47 libreoffice-impress.desktop
-rw-------   1 cris users   970 20 dic 11.47 libreoffice-math.desktop
-rw-------   1 cris users  1333 20 dic 11.47 libreoffice-startcenter.desktop
-rw-r--r--   1 cris users 25139 19 apr 14.58 libreoffice-writer.desktop
-rw-r--r--   1 cris users 25176 19 apr 17.39 libreoffice-writer-hidpi.desktop
-rw-------   1 cris users   290 18 feb 20.02 LosslessCut.desktop
-rw-r--r--   1 cris users     0 20 apr 00.11 mimeapps.list
-rw-r--r--   1 cris users 14744 22 apr 09.39 mimeinfo.cache
-rw-------   1 cris users   365  4 apr  2023 MSGViewer.desktop
-rw-r--r--   1 cris users   275 22 ott  2018 netbeans-8.2.desktop
-rw-r--r--   1 cris users  2116 22 apr  2024 org.keepassxc.KeePassXC.desktop
-rwxr-xr-x   1 cris users   579 22 apr 09.38 org.telegram.desktop._023d4009d7ff6bfa2363e883ec2f16df.desktop
-rw-------   1 cris users   414 30 gen 23.59 Portmaster.desktop
-rw-------   1 cris users   221  9 mar  2023 Postman.desktop
drwxr-xr-x   3 cris users    21 20 mar  2020 q4wine
-rw-r--r--   1 cris users   408 21 ott  2024 qb64.desktop
-rw-------   1 cris users   432 30 mar  2024 SafeDive.desktop
-rw-------   1 cris users   364 31 mar 16.51 SterlingPDF.desktop
-rw-------   1 cris users   529 18 apr  2021 teamviewer.desktop
-rw-------   1 cris users   340 24 apr  2023 Together Price.desktop
-rw-r--r--   1 cris users   522  4 mag  2022 Uninstall AssoInvoice.desktop
-rw-------   1 cris users   903 11 apr 00.59 wavebox.desktop.bak
-rw-r--r--   1 cris users   753 17 apr  2024 webapp-ProxmoxAdamo1260.desktop
-rw-r--r--   1 cris users   600 17 apr  2024 webapp-ProxmoxAlbert4730.desktop
-rw-r--r--   1 cris users   638 13 lug  2024 webapp-ProxmoxBackupServerBaR3873.desktop
-rw-r--r--   1 cris users   660 27 giu  2024 webapp-ProxmoxBackupServerQuaracchi4157.desktop
-rw-r--r--   1 cris users   584 17 apr  2024 webapp-ProxmoxBAR9428.desktop
-rw-r--r--   1 cris users   202 15 gen  2022 wine-extension-chm.desktop
-rw-r--r--   1 cris users   209 15 gen  2022 wine-extension-gif.desktop
-rw-r--r--   1 cris users   204 15 gen  2022 wine-extension-hlp.desktop
-rw-r--r--   1 cris users   220 15 gen  2022 wine-extension-htm.desktop
-rw-r--r--   1 cris users   221 15 gen  2022 wine-extension-html.desktop
-rw-r--r--   1 cris users   194 15 gen  2022 wine-extension-ini.desktop
-rw-r--r--   1 cris users   212 15 gen  2022 wine-extension-jfif.desktop
-rw-r--r--   1 cris users   211 15 gen  2022 wine-extension-jpe.desktop
-rw-r--r--   1 cris users   225 15 gen  2022 wine-extension-msp.desktop
-rw-r--r--   1 cris users   207 15 gen  2022 wine-extension-pdf.desktop
-rw-r--r--   1 cris users   209 15 gen  2022 wine-extension-png.desktop
-rw-r--r--   1 cris users   199 15 gen  2022 wine-extension-rtf.desktop
-rw-r--r--   1 cris users   194 15 gen  2022 wine-extension-txt.desktop
-rw-r--r--   1 cris users   217 15 gen  2022 wine-extension-url.desktop
-rw-r--r--   1 cris users   197 15 gen  2022 wine-extension-vbs.desktop
-rw-r--r--   1 cris users   205 15 gen  2022 wine-extension-wri.desktop
-rw-r--r--   1 cris users   207 15 gen  2022 wine-extension-xml.desktop
-rw-r--r--   1 cris users   183  1 feb  2024 wine-protocol-acrobat2018.desktop
-rw-r--r--   1 cris users   179  1 feb  2024 wine-protocol-acrobat.desktop
-rw-r--r--   1 cris users   184  1 feb  2024 wine-protocol-launchreader.desktop
-rw-r--r--   1 cris users   178  1 feb  2024 wine-protocol-mailto.desktop
-rw-r--r--   1 cris users   189  1 feb  2024 wine-protocol-reader2021.oauth2.desktop

The file libreoffice-writer-hidpi.desktop is the copy of libreoffice-writer.desktop that I wrote above (testing if KDE takes into account ~/.local/share/applications at all).
The size is different because I also changed the name internally to better distinguish the two in the applications menu.

Cris

I assume that only libreoffice-writer.desktop appears in the application menu though right? Or both are present in the menu? The permissions are as I expected.

No, both are present.
This is consistent with what I have read in other threads and with my understanding of how KDE Plasma works.
However, here the problem is that libreoffice-writer.desktop is shown in the applications menu without any extra environment variable, despite the fact that the environment variables are present in the .desktop file itself.
In this case, KDE Plasma is actually showing its counterpart present in /usr/share/applications.
On the other hand, libreoffice-writer-hidpi.desktop has no counterpart in the /usr/share/applications directory, so the applications menu is showing the correct file, with the added environment variables visible in the properties.

Ok, thanks for clarifying. Did you try clearing the cache as suggested?

Sorry, I had missed your message.
Tried it now, no difference.