How to set the preview of a plasmoid widget to a png

It does work if I manually copy my “Icon" to the desired folder and then reference it in the manifest.json. But, I don’t think that’s the way you’re supposed to do it. I have a couple of widgets I just want to figure our how to set their preview image to the one I designed in Photoshop so I could show all their available states at once. I.e

Preview image of the widget, the one that should show up in the add widget menu.

I checked this thread and the provided snippet is not working.

Any help would be appreciated.

Maybe this will help you

+1 for NothingOS style widgets :stuck_out_tongue:

1 Like

if you add widget “SCP Menu” from the widget store you can see it displays in the Add widget browser with an icon and if you look up the plasmoid in ~/.local/share/plasma/plasmoids/ you will see it uses a .desktop file instead of .json with the Icon=configure key value pair.

but if you add widget “Simple public IP` you will see that it has the same problem as your are having, using the .json file.

i tried adding the Plasmoid.icon: 'starred-symbolic' to the main.qml per the documentation, but it didn’t work

however, i found that adding the line "Icon": "configure", in between the other items under KPlugin that it would show the icon in the Widget Browser.

it did not, however, affect the icon displayed for the .json file like the .desktop does.

I tried everything mentioned there, looked at several examples but the lack of proper documentation and wording ( or perhaps it’s outdated ) is surprising while kde is known for its customisation :frowning:

I can configure from the system icons but what I want to achieve is load a custom png there just like “disk usage”, “binary clock” widgets.

Could you share me a sample code snippet of how you’ve done it if you don’t mind.

That is currently not possible, the Icon property expects a name of an icon in the icon theme:

Icon is the icon name associated with the widget. You can search for icon names in the /usr/share/icons folder.

Source: https://develop.kde.org/docs/plasma/widget/setup/#metadatajson

1 Like

That’s quite disappointing that it’s possible but wasn’t thought of :frowning: .

Could you tell me how this plasmoid does it?

gh: exequtic/apdatifier/blob/main/package/metadata.json

cant include links

It uses some very confusing scripting that puts the icon in a place where Plasma internals can pick icons (standard icon theme path).

The script is then called when the widget is added to a panel/desktop so the widget must run at least once for that trick to work.

https://github.com/exequtic/apdatifier/blob/4bd28e1d286622bff33f7fb10b70e7460aad3cac/package/contents/ui/main.qml#L141

https://github.com/exequtic/apdatifier/blob/4bd28e1d286622bff33f7fb10b70e7460aad3cac/package/contents/tools/sh/init#L18

I was wrong, see Including a custom icon for desktop widget/plasmoid? - #8 by luisbocanegra for the correct answer :sweat_smile:

Man, you’re goated. I don’t know how this was never mentioned in the documentation.

The widgets are up. Thanks for everyone’s support. ( Repo: jaxparrow07/nothing-kde-widgets )
Are there any sub threads where you could post your widgets?

how did you end up getting it working?

the only success i’ve had is using the full path in the .json file like so,

    "KPlugin": {

         "Icon": "/full/path/to/custom/icon.svg",

    }

Placed my png inside the contents folder as icon.png.
Then in the metadata.json:

    "KPlugin": {

         "Icon": "/icon.png",

    }

You can check out my repo to see how I implemented it.

thanks, that got it working on my end…glad there is a way to do this for plasmoids, but it doesn’t seem to work for service menus, unfortunately.

also, your repo doesn’t seem to have a link, which is why i asked.