 Hello everybody, currently I am at the KD Plasma Development Sprint, which means that just next door there are like 19 KD developers who hopefully don't hear me because they would make fun of me totally. So let's talk about plasmoids because well it's only fitting given where I am and they are actually much more powerful compared to what you would normally assume they are. So the basic idea of a plasmoid that is how we usually think of it is actually pretty simple. I mean there are little widgets that you can have on your desktop as an example but also like move them around and also put them in a panel as well. Those are widgets and they're kind of like on Android you also have widgets on the home screen they're not as powerful but they do have them. In fact I do think that Plasma has the most powerful system of widgets plasmoid out there because yes Apple has it iOS but also Macintosh all have widgets but it's not quite the same thing that Plasma does. You can both have them on the desktop and on the panel and they are the same one. There's not like a difference between them and if you click on them there's more content that pops out of it. So really I think it's already the most powerful widget system that's out there but it actually is much more powerful as soon as you start looking at how they actually work underneath the hood. The first thing we can notice is that you can actually put some widgets within like inside of other widgets. Just look at the system tree. I mean you have that inside of the panel and within the system tree you've got a lot of plasmoids just like you could have them outside of the system tree. In fact the system tree as we'll see in more technical detail later is a container of other plasmoids. We'll see what that means. So one cool thing that we could do and that immediately tells us that there's much more to this story than it might seems is to go check the list of all plasmoids that we have on our system and we can do that going to US Russia Plasma plasmoids and then whoa all the plasmoids with their ideas and if you go through the list there's all the ones that you would expect then some that you wouldn't especially to make an example the panel plasmoid. So there is a plasmoid called panel why? You gonna tell me why? There's also another plasmoid which is called desktop or rather desktop containment and you might ask okay what if I go into add new widget through right click and I try to search for panel or desktop I don't get any panel plasmoid or desktop plasmoid so what are those? So here's the thing the panel plasmoid is actually your panel and the desktop containment plasmoid is actually your desktop the the whole desktop and the whole panel are plasmoids just like any other widget that you would put inside the panel or the desktop. This should be quite a wait what moment for you but we'll see how that makes sense. So basically each plasmoid has a meta data file and within that meta data file along with name orders and such there's also another property that tells us whether whether that plasmoid is more like an applet that you can put around and move around or more like a containment which you cannot move around but you can in some cases yes but you can also put other applets inside of it. So why would you do something like that? Why isn't desktop or panel just another different thing compared to the same plasmoids that we use as applets on our desktop and panel? Well there is a good reason and I think it's best explained to another both applet and containment plasmoid which is the folder view so you know how you can add your folder view to your desktop and you can also add a folder view in your panel but the thing is that you might want to have a desktop that has you know folders normally in fact the folder view is not just an applet but also a containment which means that you can act as a desktop. When you have folders on your desktop that's the same exact code and if you have folders applet in your desktop because that's the same code they're both plasmoids one plasmoid is used as an applet the other plasmoid is used as a container but same code and this actually allows to save a lot of time because if we had to implement the same exact code in two different times just to do the desktop and then the applet well that would be quite a lot of work. Finally this results in a mild existential crisis of the folder applet as one of the very first thing it does in its code is to check whether it's an applet a containment and whether it's a desktop or without folders so folder view and whether it's inside of a pop-up or not so quite a lot of things to accomplish at once but it successful successfully does it. Now to fully understand what's going on we have to go underneath the hood and talk about a plasmoid api which will soon maybe change because of plasmas 6 but right now there are two main components which is applet and containment there's actually no plasmoid that's the name of the whole idea but when you actually see the api it's applet and containment and only enough the containment is an applet it's just it has more stuff to it but it's an applet so what properties do we have by using this applet api and then what other properties do we get as a bonus if we use the containment api and remember that all of this is still within just the plasmoids concept so the applet interface has a lot of things there has ways to change the configuration of the applet obviously when you try to customize it information about the screen like this its size and such where the applet is placed like it's on the top bottom left right what icon should it use whether edit mode is enabled or not and all of these are things that applet can read and sometimes also set so info coming out and in from the applet one very important information is representations so let's talk representations so take a clock widget in the banner as an example it's going to look like a clock with inside of it you know the date if you click on it you get a pop-up that tells you you know that shows you your calendar if you instead use the same applet but on your desktop then it depends on what size it is if it's small then it's still going to be just the clock but if you change its size so it's much bigger then it's automatically gonna become a calendar and this is because the clock widget has two different representations the compact representation which is just the clock and the full representation which is the full calendar and you have some properties such as switch height that allows you to tell the applet at which size you should switch between the full representation and the compact representation so that when you resize it if it's larger than the switch height then you know full representation it is finally some applets don't quite have two different representations or rather they just have one which is the full representation and they just say hey please always use the full representation don't try to force a compact representation on me i just don't need it other applets you might have noticed use kind of the same that like there's a lot of applets using the same compact representation that is just an icon in the panel usually that you can click to have more dialogues popping up with actual info so instead of each applet implementing their own compact representation which very often is going to be the same one that's needed by other applets as well like you know a simple icon there is a default compact representation that is used throughout applets what does it do well it shows an icon the icon that was asked by the plasmoid and if you click on it then that's gonna bring up a plasmoid with the full representation inside of it that's the idea the script here says hopefully this whole thing is making sense is it now that i've talked about applets since now time to switch to containment so what do they have that applets don't have well a critical property that they do have is the property called applets well given that containments are formally allowed to have applets within them they do have this property applet that tells you which applets are inside of that containment even though the containment is kind of an applet itself so in theory you could have a containment inside that containment another applet that's also containment and inside that one another applet so it becomes a tree structure if we want to do that which we do by the way because you know i talked about the assistant tree and how the assistant tree contains applets inside of it and then there's the panel which also contains applets inside of it so the panel is a containment the assistant tree is a containment and we just within the assistant tree are within the assistant tree containment which is within that panel containment this makes sense right right we do have all different kinds of containment in other caty plasma flavors caty plasma mobile as an example has a couple of them that look and behave very differently in one you can put widgets on the desktop in the other one you've got like a list of applications that you can open it's a bit like home screens but for plasma and the home screens are the same thing as widgets that you can put on the home screen wow by the way all containment if i understood this correctly either have to declare themselves as desktops or panels it's one of the two and the assistant tree proudly self identifies as a panel so we should refer to the assistant tree as a panel this kind of also relates in an interesting way or at least you can get a lot of useful information from looking at the config files of this whole thing where is all the information about the config of containers and applets and how they relate of each other to each other saved like how does plasma know well there are a couple of files the first one is called plasma rc yeah which has all the global information about plasma we actually don't care about it right now because this whole applet continuance thingy that's happening is happening within our show and plasma is not a show plasma desktop is so if you had as an example plasma desktop and plasma mobile on the same computer you would have one file for plasma desktop and one file for plasma mobile so we need to go check the file that is for plasma desktop specifically not just about plasma in general and they are two different things inside of that file which you will see one or more probably more containers with an id number containing all the important information about the containment that's themselves so their size their position and so on then there is basically list of applets and each applet has an id number and it has a containment that's inside of which is the important point and within that link we could say between the applet and the containment you also have all the config informations of that certain applet if you want to add some applets finally enough you can just you know actually add a new line with a new id for the applet and add the id name of the applet and just put the config and then restart the plasma shell and it's gonna read that applet directly from the config file why should you do this well it actually kind of saved me because i was working on a project a secret project that i've talked many times about at this point and basically i have to create a new plasma shell for a new kind of the device and one thing i have to do is show applets so there has to be like a wi-fi and a volume thingy and it's very simple so i don't actually want to implement a full panel so i just have my plus mode which is the home screen and of course that's a containment so i set it as a containment and now i actually want to put some widgets inside of it so normally how i would do that is through the javascript file that is run when you start a shell and usually you can add widgets through that javascript file but if you watched my two videos ago where i did a devlog about floating dialogs and such and i know you didn't watch it so go watch it i talked about how this actually didn't work due to a bug in x11 so what i did was simply to directly add the applet within the config file itself because you know that was gonna save so much time in development and i don't have that so to recap we've got plus modes that are not just the thing is you have on your desktop but you can actually move them around put them in your panel and they have two different representations they can switch dynamically between representations there's a common representation for all of them and then they have a specific four one and also they are the same thing as the panel and the desktop and you can use plus i would say they're you know pretty powerful