Search code examples
jsonxmlqtkde-plasma

"Could not locate package metadata" error after clicking the configure button of a desktop effect KDE


I've been developing a config menu for this kwin desktop effect and I am getting a popup, instead of the UI of the configure menu, and it says:

Could not locate package metadata

error

Here are my directory structure, ui, config and metadata files since they will be important later.

Directory structure

kwin4_effects_foldpopups
├── contents
│   ├── code
│   │   └── main.js
│   ├── config
│   │   └── main.xml
│   └── ui
│       └── config.ui
└── metadata.json

ui/config.ui

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>FoldPopupsEffectConfig</class>
 <widget class="QWidget" name="FoldPopupsEffectConfig">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>338</width>
    <height>89</height>
   </rect>
  </property>
  <property name="sizePolicy">
   <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
    <horstretch>0</horstretch>
    <verstretch>0</verstretch>
   </sizepolicy>
  </property>
  <property name="windowTitle">
   <string>Fold Popups Effect Configuration</string>
  </property>
  <layout class="QGridLayout" name="grid_layout">
   <item row="0" column="0">
    <widget class="QLabel" name="duration_label">
     <property name="text">
      <string>Animation Duration</string>
     </property>
     <property name="alignment">
      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
     </property>
    </widget>
   </item>
   <item row="0" column="1">
    <widget class="QSpinBox" name="kcfg_Duration">
     <property name="suffix">
      <string> milliseconds</string>
     </property>
     <property name="minimum">
      <number>300</number>
     </property>
     <property name="maximum">
      <number>5000</number>
     </property>
     <property name="singleStep">
      <number>10</number>
     </property>
    </widget>
   </item>
   <item row="1" column="0">
    <widget class="QLabel" name="behavior_label">
     <property name="text">
      <string>Animation Behavior</string>
     </property>
     <property name="alignment">
      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
     </property>
    </widget>
   </item>
   <item row="1" column="1">
    <widget class="QLabel" name="tbc_label">
     <property name="text">
      <string>To be continued</string ><!-- TODO: Add behaviour options here -->
     </property>
     <property name="alignment">
      <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
     </property>
    </widget>
   </item>
  </layout>
 </widget>
 <resources/>
 <connections/>
</ui>

config/main.xml

<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
  <kcfgfile name=""/>
  <group name="">
    <entry name="Duration" type="UInt">
      <default>300</default>
    </entry>
  </group>
</kcfg>

metadata.json

{
    "KPackageStructure": "KWin/Effect",
    "KPlugin": {
        "Name": "Fold Popups",
        "Name[zh_CN]": "气泡折叠动画",
        "Description": "Make popups smoothly fold in and out when they are shown or hidden",
        "Comment[zh_CN]": "气泡信息显示/隐藏时呈现折叠过渡动画",
        "Category": "Appearance",
        "Authors": [
            {
                "Email": "[email protected]",
                "Name": "kde-yyds"
            }
        ],
        "Icon": "preferences-system-windows-effect-fadingpopups",
        "Id": "kwin4_effects_foldpopups",
        "License": "GPL",
        "Version": "1.0",
        "EnabledByDefault": "true",
        "ServiceTypes": ["KWin/Effect"]
    },
    "Type": "Service",
    "X-KDE-Ordering": "60",
    "X-KDE-PluginKeyword": "kwin4_effects_foldpopups",
    "X-KDE-ConfigModule": "kwin/effects/configs/kcm_kwin4_genericscripted",
    "X-KWin-Config-TranslationDomain": "kwin_effects",
    "X-Plasma-API": "javascript",
    "X-Plasma-MainScript": "code/main.js",
    "X-KDE-ParentApp": "kwin"
}

I've tried reading the documentation and doing what it says to do, copying metadata files of other desktop effects that had a working configure menu and modifying them but it didn't work.

I even modified metadata files of other and realized when Id parameter is different than the directory name, other effects also gave the same error. But what's really weird is my Id is exactly the same as the directory name of the effect.


Solution

  • This took some digging after I ran into the same problem.

    The very short version is that you need to rename your effects plugin.

    It must start with, exactly, kwin4_effect_, otherwise genericscriptedconfig will decide that you're a script instead of a scripted event, and look in .local/config/kwin/scripts/ instead of .local/config/kwin/effects/

    I have yet to find documentation that explicitly covers this, I found it by digging into the code.