How to add touchpad and battery for notebooks

Marco Martin notmart at gmail.com
Fri Apr 6 14:51:16 UTC 2018


On Thu, Apr 5, 2018 at 11:38 AM, Ludwig Cornelius <t_d_l_c at gmx.de> wrote:
> Hi dear mailing list,
>
>
> I want to add the widgets for touchpad and battery on notebooks
> automatically by using a script or configuration file. Is this possible?

Hi,
isn't the battery automatically there for laptops?

anyways, the systray changed a bit in plasma5, to find it you can do
as following,
I have adapted from a portion of your script to add the "print
manager" widget in the systray, you probably want to replace that with
widgetName.
A simplified version is also on the docs now:
https://userbase.kde.org/KDE_System_Administration/PlasmaDesktopScripting#Advanced_example:_Adding_a_widget_to_the_System_Tray

pids = panelIds;
for (i = 0; i < pids.length; ++i) { //search through the panels
    panel = panelById(pids[i]);
    if (!panel) continue;

    for (tmpIndex = 0; tmpIndex < panel.widgetIds.length; tmpIndex ++) {
        appletWidget = panel.widgetById(panel.widgetIds[tmpIndex]);
        // l(0, appletWidget.type);
        if (appletWidget.type == widgetName) {
            l(1, widgetName + " already in panel");
            return;
        }
        else if (appletWidget.type == "org.kde.plasma.systemtray") {
            systemtrayId = appletWidget.readConfig("SystrayContainmentId");
            if (systemtrayId) {
               print("systemtray id: " + systemtrayId)
               var systray = desktopById(systemtrayId);
               systray.currentConfigGroup = ["General"];
               var extraItems = systray.readConfig("extraItems").split(",");
               if (extraItems.indexOf("org.kde.plasma.printmanager") === -1) {
                   extraItems.push("org.kde.plasma.printmanager")
                   systray.writeConfig("extraItems", extraItems);
                   systray.reloadConfig();
               }
               print(extraItems);
            }
        }
    }
}


--
Marco Martin


More information about the Enterprise mailing list