Hello everyone,
a while ago I developed a simple Plasma widget to control the RGB settings of my laptop. By default the widget is placed in the system tray but it can alternatively be placed on a panel or on the desktop.
The widget has an option to restore the last used RGB settings when the user logs in (when the widget is loaded / created).
Under Plasma 5 this worked without issue but when I ported the widget over to Plasma 6 I noticed that it would no longer restore the last used settings when the widget is placed in the system tray.
It still works fine when the widget is placed on a panel or on the desktop but in the system tray it will only trigger when clicked on by the user.
I have very little experience developing Plasma widgets or working with QML in general so I haven’t been able to determine whether I’m doing something wrong and what the intended behaviour of Plasma 6 is in this case.
Under Plasma 5 my code basically looked like this:
Item {
...
Plasmoid.fullRepresentation: ColumnLayout {
Component.onCompleted: {
MyAction()
}
...
}
}
Despite being only present in the fullRepresentation part of the widget under Plasma 5 MyAction() would trigger in every representation, including the system tray.
When I noticed that it would no longer trigger unter Plasma 6 I additionally tried adding the onCompleted event in the compactRepresentation but it made no difference.
Any ideas?
Code to the Plasma 5 widget: GitHub - x211321/RGB-Config-Acer-gkbbl-0-Plasma-Widget: A KDE plasma widget for controlling RGB settings of the Acer-WMI kernel module via the acer-gkbbl-0 character device
Code to the Plasma 6 widget: GitHub - x211321/RGB-Config-Acer-gkbbl-0-Plasma-Widget-Plasma6: A KDE plasma widget for controlling RGB settings of the Acer-WMI kernel module via the acer-gkbbl-0 character device
Have you tried using the Component.onCompleted
on the base PlasmoidItem
instead of the Plasmoid.fullRepresentation
(or compact)?
I haven’t tested this with your widget specifically and don’t have an Acer laptop to test with, but I’ve just tried with the Clipboard plasmoid (as a tray item) in a VM by copying a version to the home folder as an override and I added a console.log
output, which showed up in the journal, and on that basis I assume it should work.
Edit: I noticed you have a note about setting the color of the icon and I’ve worked with some plasmoid code around colors with the Pager plasmoid. Since you’re already doing a Kirigami import, have you tried using the Kirigami theme colors to apply the icon color automatically?
As a reference point, the Pager plasmoid uses Kirigami.Theme.textColor
, which on a panel set to Breeze Dark shows as white, and on a panel set to Breeze / Breeze Light shows as white.
That said, even if you did want to have it color automatically, you might still want to leave an option in to allow custom icon coloring if people might already want to do that.
2 Likes
Hey, thanks for your reply.
I tried it like this
PlasmoidItem {
id: root
Component.onCompleted: {
updateRGBMode(plasmoid.configuration.applyOnStartup)
}
...
But it doesn’t seem to make a difference. Still only triggering when the widget is not in the system tray or when actively clicked by the user.
Te me it feels like Plasma 6 no longer activates widgets in the system tray the same way as Plasma 5 did before but I know too little about the topic.
I haven’t tested this with your widget specifically and don’t have an Acer laptop to test with
You could test it without an Acer laptop if you wanted. The widget will show an error message when the RGB device is not available. If the message is shown the function is triggered correctly.
Thanks for the hint about the icon color, I’ll look into that. It’s been a while since I last tinkered with that widget so my memory of what I tried before is not all that fresh.
I don’t mean to double post but It seems like I no longer can edit my previous message.
I just tried outputting a log message instead, as you described above, and you are absolutely right, onCompleted gets triggered.
Instead I get other errors which I have not noticed before:
file:///home/**/.local/share/plasma/plasmoids/com.github.x211321.rgb-config-acer-gkb
bl-0-plasma-widget/contents/ui/main.qml:22: ReferenceError: updateRGBMode is not def
ined
file:///home/**/.local/share/plasma/plasmoids/com.github.x211321.rgb-config-acer-gkb
bl-0-plasma-widget/contents/ui/main.qml:62: ReferenceError: updateRGBMode is not def
ined
qt.qml.context: file:///home/**/.local/share/plasma/plasmoids/com.github.x211321.rgb
-config-acer-gkbbl-0-plasma-widget/contents/ui/main.qml:175:13 Parameter "data" is n
ot declared. Injection of parameters into signal handlers is deprecated. Use JavaScr
ipt functions with formal parameters instead.
Seems like I have some more work to do. Thanks a lot this put me on the right track.
I still don’t really understand why it works in the other situations though.
Yet again too late to edit.
I just noticed that I have defined updateRGBMode in the fullRepresentation scope, this explains why it is not available before the fullRepresentation is initialized. Seems like I didn’t catch that because I was so fixated on the fact that it worked under Plasma 5.
Seems like I have to get a better grip on QML. Thanks again for your help, I believe I can figure the rest out myself.
I was just writing about the updateRGBMode
scope and was just testing it out when you replied, but then ran into an error around comboboxRGBMode
, so I’m guessing there are likely to be some issues to resolve around sequencing/timing of executing the update function.
1 Like
Yes, I came to the same result. Seems like I will have to work around the controls when the representation, that contains them, is not yet initialized. I’ll figure something out, you have been a great help. I really missed the forest for the trees when I thought the event was not triggering.
Glad to have provided some help!
Just some additional things I noticed when I reverted the code back to the original Plasma 6 code, I added a console.log command into the start of the updateRGBMode
function and it did actually output the console logging, but it looks like there are other errors and I’m currently assuming it might be more related to the DataSource
.
1 Like
Yes, to me it seems like the difference between Plasma 5 and Plasma 6 is not whether the event gets triggered or not but that Plasma 5 apparently fully initialized the fullRepresentation even if it has not been activated yet.
Plasma 6 seems to only fully initialize the fullRepresentation once it is shown, either by being in that representation from the start or when the user clicks on the tray icon to show the fullRepresentation. I guess this was changed for performance reasons, totally makes sense.
My mistake was having stuff declared in the scope of the fullRepresentation which is used outside of it.
I got it working now. Again thank you for your help. Next I’ll look into the theme colors you pointed me too.
This topic is now fully resolved 
1 Like
That’s great!
I wasn’t sure how far you’d gotten and was actually just putting together another edit on my previous comment since I’d continued testing and discovered how to handle the data
error and then found that the Python script was throwing a ValueError that wasn’t being picked up via stderr
.
Glad you’ve got it working again!