Convert desktop files to JSON files if they are only used for plugin metadata
Open, Needs TriagePublic

Description

If the ServiceTypes are phased out the desktop files which contain the property-definitions should also be phased out.

Except for the KCMs there is no known case where we need to have both desktop files and JSON metadata available. KPackage can also handle JSON metadata for the appstream generation & all other functionalities.

Consequently we should just the metadata in the JSON format in version control. When converting the files one should check if the properties are really needed (see T14483) and clean them up if not. In case of KPackages this is still needed! When making a merge requests the translators should be pinged so they can ignore the file changes (the actual strings should not change).

alex created this task.Jun 8 2021, 1:04 PM
alex updated the task description. (Show Details)Jun 8 2021, 1:13 PM

One aspect to consider is that desktop files are IMHO a bit nicer for humans to edit than json, so we might want to still use those as source but install only the json files

alex added a comment.EditedJul 29 2021, 4:39 PM

I disagree that it is nicer to edit, especially because some of the property names are changed after the JSON conversion and some are not convertet at all. Like the mentioned X-KDE-Library in T14757.

I think that the keys used should be the same as their accessor in KPluginMetaData. Like the comment key in the desktop files is called description in the JSON metadata.
Also in the JSON files multiple authors can be put inside of the JSON array, int the desktop file there is only a single X-KDE-PluginInfo-Author field.

Also in quite a lot of places there are already JSON files in VSC, converting the rest of them would make it more consistent.

And as discussed in the other tasks the service types should disappear, but they are currently (almost exclusively) used for the JSON file conversion. There are also issues with the desktop conversion, for example translated strings are not handled very well or the correct service types could not be found during the build. This was an issue when I introduced a new KRunner property which was a bool.

alex added a comment.Sep 3 2021, 7:19 PM

Notes from KF6 weekly:

  • https://phabricator.kde.org/T14564: There are a number of good reasons to consistently use JSON files, desktop files for editing might be nicer, but those files are rarely edited and mainly contain scripty generated content.
alex moved this task from Backlog to In Progress on the KF6 board.Dec 28 2021, 4:54 PM

I'm confused, what should I do if I'm porting an old KCM?
Should I remove the desktop file all together and install json instead? If so, where can I get the json file.
Or should I convert the desktop file to json but still install the desktop file?
Or should I convert the desktop file to json and install json, but still keep the desktop file?

I've seen your MRs, but I'm confused why you added desktop to json conversion and then remove it in the next MR

alex added a comment.Feb 17 2022, 5:24 PM

You should install a desktop file with the translated name and a few other keys, see https://invent.kde.org/plasma/plasma-workspace/-/blob/master/kcms/autostart/kcm_autostart.desktop#L40 until the end of the file.

The KCM should have embedded json metadata, which contains additional info like the systemsettings categories, description & keywords.

If so, where can I get the json file.

desktoptojson -i myfile.desktop

but I'm confused why you added desktop to json conversion and then remove it in the next MR

I wanted to do the json conversion in one go, otherwise life would have been more difficult for translators. The json conversion code was needed to port the deprecated systemsettings KCM querying. Because this was a big change across multiple repos already, I wanted it to get merged before working on the conversion.

alex added a comment.Feb 17 2022, 5:57 PM

If you need further help, I can push a change to a Mr/branch if you like

alex added a comment.Feb 17 2022, 5:58 PM

If you need further help, I can push a change to a Mr/branch if you like

FWIW I haven't found editing a JSON file to be any worse than editing a .desktop file. My preference would be to autogenerate all the relevant autogeneratable .desktop files and have a single JSON file as only one source of truth.

alex added a comment.Feb 26 2023, 10:52 AM

For reference: The CMake function kcmutils_generated_desktop_file landed a while ago. For KCMs we now only have a json file for the metadata.

I think we can consider this done from a frameworks perspective. There are still apps that need to be fixed though

nicolasfella moved this task from In Progress to Done on the KF6 board.May 28 2023, 9:29 PM