DESCRIPTION I'm attempting to write a Plasma script that will add a clickable icon widget next to an existing widget already in my panel. (This could be done via edit mode, but I'm scripting it so I can automate it across multiple machines.) According to https://develop.kde.org/docs/plasma/scripting/api/#widgets, I read a widget's `index` property to determine where it is in the panel, and can write to that property to change where it is in the panel. This however does not work; all widgets have an index of -1 when reading them, and writing a new value to a widget's index appears to be a no-op. STEPS TO REPRODUCE 1. Open plasma-interactiveconsole. 2. Paste the following code in and run it: ``` panelIds.forEach((panelId) => { let panel = panelById(panelId); if (!panel) { return; } panel.widgetIds.forEach((appletWidgetId) => { let appletWidget = panel.widgetById(appletWidgetId); if (appletWidget.type === "org.kde.plasma.kickoff") { const newWidget = panel.addWidget('org.kde.plasma.icon'); newWidget.index = appletWidget.index; newWidget.writeConfig( 'localpath', '/usr/share/applications/org.kde.kate.desktop' ); newWidget.currentConfigGroup = [ 'General' ]; newWidget.writeConfig( 'url', 'file:///usr/share/applications/org.kde.kate.desktop' ); } }); }); ``` OBSERVED RESULT A Kate launcher icon is added at the "end" of the panel (the far right edge if using a horizontal panel at the bottom of the screen), far away from the Application Launcher button. If you print `appletWidget.index`, you will see it has a value of -1. Setting `newWidget.index` to a hardcoded positive value has no effect on the behavior. EXPECTED RESULT A Kate launcher icon is added right next to the Application Launcher button. SOFTWARE/OS VERSIONS Operating System: Kubuntu 26.04 LTS KDE Plasma Version: 6.6.6 KDE Frameworks Version: 6.24.0 Qt Version: 6.10.2 ADDITIONAL INFORMATION n/a
Created attachment 194738 [details] What my panel looked like before running the script
Created attachment 194739 [details] What I thought the panel would look like after running the script
Created attachment 194740 [details] What the panel actually looks like after running the script
Indeed, in plasma6 applet.index is not implemented. now, i'm not sure how to actually implement it as it seems to be a stub since plasma5 (the old actual implementation seems to be KDE4 based) I'll give it a try to see if i can have an implementation that works on the current panel architecture in the meantime, a workaround that is as small as possible (and reliable for now) is: panelIds.forEach((panelId) => { let panel = panelById(panelId); if (!panel) { return; } panel.widgetIds.forEach((appletWidgetId) => { let appletWidget = panel.widgetById(appletWidgetId); if (appletWidget.type === "org.kde.plasma.kickoff") { const x = appletWidget.geometry.x + appletWidget.geometry.width / 2 const y = appletWidget.geometry.y + appletWidget.geometry.height / 2 const newWidget = panel.addWidget('org.kde.plasma.icon', x + 1,y + 1); //newWidget.index = appletWidget.index; newWidget.writeConfig( 'localpath', '/usr/share/applications/org.kde.kate.desktop' ); newWidget.currentConfigGroup = [ 'General' ]; newWidget.writeConfig( 'url', 'file:///usr/share/applications/org.kde.kate.desktop' ); } }); });
Git commit 6f2cbab5ca795d8ac2a05a4f6b9e2904829d931c by Marco Martin. Committed on 06/08/2026 at 13:17. Pushed by mart into branch 'master'. Scripting: restore Applet::index property on panels use the config to the index order and use the reorderApplets() function that the panel containment exposes to apply a different index Depends from https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/3926 M +37 -21 shell/scripting/widget.cpp https://invent.kde.org/plasma/plasma-workspace/-/commit/6f2cbab5ca795d8ac2a05a4f6b9e2904829d931c
Git commit 21cbb732ab85093b6c89340fe93396edae824a35 by Marco Martin. Committed on 06/08/2026 at 13:41. Pushed by mart into branch 'master'. Panel: expose reorderApplets() function for scripting Expose a reorderApplets function which takes a list of applet ids and reorders the known applets consistent to such list. Depends from https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/6895 M +17 -0 containments/panel/LayoutManager.js M +8 -0 containments/panel/main.qml https://invent.kde.org/plasma/plasma-desktop/-/commit/21cbb732ab85093b6c89340fe93396edae824a35
Git commit afdd265164ecbf75ff129d49f8c644d510ebfcd3 by Marco Martin. Committed on 13/08/2026 at 14:30. Pushed by mart into branch 'Plasma/6.7'. Scripting: restore Applet::index property on panels use the config to the index order and use the reorderApplets() function that the panel containment exposes to apply a different index Depends from https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/3926 (cherry picked from commit 6f2cbab5ca795d8ac2a05a4f6b9e2904829d931c) 97e8d546 Scripting: restore Applet::index property 723a0db1 make index and setindex work Co-authored-by: Marco Martin <notmart@gmail.com> M +37 -21 shell/scripting/widget.cpp https://invent.kde.org/plasma/plasma-workspace/-/commit/afdd265164ecbf75ff129d49f8c644d510ebfcd3
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/3946
Git commit 4218bb0612913466e90258babdc596f7851c5e70 by Marco Martin. Committed on 13/08/2026 at 14:33. Pushed by mart into branch 'Plasma/6.7'. Panel: expose reorderApplets() function for scripting Expose a reorderApplets function which takes a list of applet ids and reorders the known applets consistent to such list. Depends from https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/6895 (cherry picked from commit 21cbb732ab85093b6c89340fe93396edae824a35) e115f36d Panel: expose reorderApplets() function for scripting Co-authored-by: Marco Martin <notmart@gmail.com> M +17 -0 containments/panel/LayoutManager.js M +8 -0 containments/panel/main.qml https://invent.kde.org/plasma/plasma-desktop/-/commit/4218bb0612913466e90258babdc596f7851c5e70
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/3947
Git commit 8655994ff47a6ba740a29727a7cf597cc2fa06c8 by Marco Martin. Committed on 13/08/2026 at 14:32. Pushed by mart into branch 'Plasma/6.6'. Scripting: restore Applet::index property on panels use the config to the index order and use the reorderApplets() function that the panel containment exposes to apply a different index Depends from https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/3926 (cherry picked from commit 6f2cbab5ca795d8ac2a05a4f6b9e2904829d931c) 97e8d546 Scripting: restore Applet::index property 723a0db1 make index and setindex work Co-authored-by: Marco Martin <notmart@gmail.com> M +37 -21 shell/scripting/widget.cpp https://invent.kde.org/plasma/plasma-workspace/-/commit/8655994ff47a6ba740a29727a7cf597cc2fa06c8
Git commit b9feaa22f4fff6b3ec9e965f9b4a656db2ba10ac by Marco Martin. Committed on 13/08/2026 at 14:34. Pushed by mart into branch 'Plasma/6.6'. Panel: expose reorderApplets() function for scripting Expose a reorderApplets function which takes a list of applet ids and reorders the known applets consistent to such list. Depends from https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/6895 (cherry picked from commit 21cbb732ab85093b6c89340fe93396edae824a35) e115f36d Panel: expose reorderApplets() function for scripting Co-authored-by: Marco Martin <notmart@gmail.com> M +17 -0 containments/panel/LayoutManager.js M +8 -0 containments/panel/main.qml https://invent.kde.org/plasma/plasma-desktop/-/commit/b9feaa22f4fff6b3ec9e965f9b4a656db2ba10ac