Hopefully this is the right section to put this in. Wasn’t sure if I should go with here or the help section.
I am trying to develop a Plasma script that can either delete and recreate or move my panel to a different screen. According to the documentation, there is a property of screen
on the Panel
object but it is only read only and can not be modified.
I was originally trying to use the following code to delete and recreate my Panel:
var allPanels = panels();
// Remove all existing panels
for (var panelIndex = 0; panelIndex < allPanels.length; panelIndex++) {
var p = allPanels[panelIndex];
p.remove();
}
// Define the widgets for the new panel
var widgets = [
"org.kde.plasma.kickoff",
"org.kde.plasma.pager",
"org.kde.plasma.marginsseparator",
"org.kde.plasma.icontasks",
"org.kde.plasma.systemtray",
"org.kde.plasma.digitalclock",
"org.kde.plasma.showdesktop"
];
// Create a new panel
var newPanel = new Panel;
newPanel.location = "top";
newPanel.hiding = "autohide";
newPanel.floating = false;
newPanel.height = 48;
// Add all widgets to the new panel
for (const widgetType of widgets) {
newPanel.addWidget(widgetType);
}
// Apply the pinned apps as soon as the widgets are added
for (const widget of newPanel.widgets()) {
if (widget.type === "org.kde.plasma.icontasks") {
// Clear existing pinned apps by setting it to an empty string
// Now apply the desired pinned apps
var launchers = [
"applications:org.kde.dolphin.desktop",
"applications:firefox.desktop",
"applications:org.kde.konsole.desktop"
]
// Write the launchers list as a single string
widget.writeConfig("launchers", launchers.join(";"));
widget.reloadConfig();
}
}
print("\nPanel setup complete.");
However the the problem I ran into is that when I tried to use the launchers string. It did not create multiple applications for reach launcher in the string. It created one application with the entire string. Like this:
When I only had one application it worked. but doing multiple applications in this string format doesn’t seem to work for me.
I am thinking this is a convoluted way of being able to move the panel, and there should be an easier way, but Im not 100% sure. It would be nice if I could just figure out why this code is not working and continue to use this script. That would be viable enough for me. I can just add this to my script that configures my monitors when I switch between using my laptop, and plugging into my desk setup. I would greatly appreciate any help or potential solutions