Plasma API Scripting - Set SystemTray properties in layout.js of Global Theme

Hello,

We use Plasma API Scripting for our distro’s Global Theme but there are 2 changes I am unable to figure out what I’m missing to make it work. I will open one thread per question.

In this thread it will be about setting configuration properties for Plasma System Tray. The other question/thread will follow in due time.

I have read many documentations (a few here below) and still fails to apply one single change to the systray. Unfortunately, being a new user I can only put 2 URLs in a post (I have 7). I will go the most important:

I am trying to configure 2 properties that would apply when the user selects the Global Theme:

  1. Set “Scale Icons to Fit” to TRUE
  2. Set which systray icons should always be shown

I am using this file to set the Theme:

/usr/share/plasma/look-and-feel/Dr460nized/contents/layouts/org.kde.plasma.desktop-layout.js

var plasma = getApiVersion(1)

// Center Krunner on screen - requires relogin
const krunner = ConfigFile(‘krunnerrc’)
krunner.group = ‘General’
krunner.writeEntry(‘FreeFloating’, true);

// Change keyboard repeat delay from default 600ms to 250ms
const kbd = ConfigFile(‘kcminputrc’)
kbd.group = ‘Keyboard’
kbd.writeEntry(‘RepeatDelay’, 250);

// Create Top Panel
const panel = new Panel
panel.location = “top”
panel.alignment = “left”
panel.height = Math.round(gridUnit * 1.5);

// The order in which the below Applets are listed will be reflected from Left to Right in the Top Panel.

// The Kickoff launcher
var launcher = panel.addWidget(“org.kde.plasma.kickoff”)
launcher.currentConfigGroup = [“General”]
launcher.writeConfig(“icon”, “distributor-logo-garuda”)
launcher.writeConfig(“lengthFirstMargin”, 7)
launcher.currentConfigGroup = [“Shortcuts”]
launcher.writeConfig(“global”, “Alt+F1”)

// Window buttons
var buttons = panel.addWidget(“org.kde.windowbuttons”)
buttons.currentConfigGroup = [“General”]
buttons.writeConfig(“buttonSizePercentage”, 42)
buttons.writeConfig(“containmentType”, “Plasma”)
buttons.writeConfig(“inactiveStateEnabled”, true)
buttons.writeConfig(“lengthFirstMargin”, 10)
buttons.writeConfig(“lengthLastMargin”, 4)
buttons.writeConfig(“lengthMarginsLock”, false)
buttons.writeConfig(“spacing”, 6)
buttons.writeConfig(“useDecorationMetrics”, false)
buttons.writeConfig(“visibility”, 2)

// Window Title
var title = panel.addWidget(“org.kde.windowtitle”)
title.currentConfigGroup = [“General”]
title.writeConfig(“filterActivityInfo”, false)
title.writeConfig(“lengthFirstMargin”, 7)
title.writeConfig(“lengthMarginsLock”, false)
title.writeConfig(“placeHolder”, “Dr460nized KDE :fire:”)
title.writeConfig(“showIcon”, false)
title.writeConfig(“filterByScreen”, true)

// Window AppMenu
var appmenu = panel.addWidget(“org.kde.windowappmenu”)
appmenu.currentConfigGroup = [“General”]
appmenu.writeConfig(“fillWidth”, true)
appmenu.writeConfig(“toggleMaximizedOnDoubleClick”, true)
appmenu.writeConfig(“filterByScreen”, true)
appmenu.writeConfig(“spacing”, 4)

// Add Left Expandable Spacer
var spacer = panel.addWidget(“org.kde.plasma.panelspacer”)

// Better Inline Clock
var inlineclock = panel.addWidget(“org.kde.plasma.betterinlineclock”)
inlineclock.currentConfigGroup = [“Appearance”]
inlineclock.writeConfig(“boldText”, true)
inlineclock.writeConfig(“enabledCalendarPlugins”, “/usr/lib/qt/plugins/plasmacalendarplugins/alternatecalendar.so,/usr/lib/qt/plugins/plasmacalendarplugins/astronomicalevents.so,/usr/lib/qt/plugins/plasmacalendarplugins/holidaysevents.so”)
inlineclock.writeConfig(“fontFamily”, “Noto Sans”)
inlineclock.writeConfig(“showSeconds”, false)
inlineclock.writeConfig(“showWeekNumbers”, true)
inlineclock.writeConfig(“use24hFormat”, 2)

// Add Right Expandable Spacer
var spacer = panel.addWidget(“org.kde.plasma.panelspacer”)

// System Tray
panel.addWidget(“org.kde.plasma.systemtray”)

// User Switcher
var switcher = panel.addWidget(“org.kde.plasma.userswitcher”)
switcher.currentConfigGroup = [“General”]
switcher.writeConfig(“showFace”, true)
switcher.writeConfig(“showName”, false)
switcher.writeConfig(“showTechnicalInfo”, true)

// Create bottom panel (Dock)
const dock = new Panel

// Basic Dock Geometry
dock.alignment = “center”
dock.height = Math.round(gridUnit * 2.8);
dock.hiding = “windowscover”
dock.location = “bottom”
dock.maximumLenth = 1000
dock.minimumLength = 250

// Icons-Only Task Manager
var tasks = dock.addWidget(“org.kde.plasma.icontasks”)
tasks.currentConfigGroup = [“General”]
tasks.writeConfig(“fill”, false)
tasks.writeConfig(“iconSpacing”, 2)
tasks.writeConfig(“launchers”, “applications:garuda-welcome.desktop,applications:org.kde.konsole.desktop,preferred://browser,preferred://filemanager,applications:org.kde.plasma-systemmonitor.desktop,applications:snapper-tools.desktop,applications:systemsettings.desktop,applications:octopi.desktop”)
tasks.writeConfig(“maxStripes”, 1)
tasks.writeConfig(“showOnlyCurrentDesktop”, false)
tasks.writeConfig(“showOnlyCurrentScreen”, false)

Dr460nized is the name of the Theme.
The systray section is not part of the above script cuz I prefer to discuss about it below.
The wallpaper is set by other means, following bug 465893 (again cannot put the link).

When manually setting the properties it should like this, in the below groups, in ~/.config/plasma-org.kde.plasma.desktop-appletsrc:

[Containments][10][General]
extraItems=org.kde.kdeconnect,org.kde.kscreen,org.kde.plasma.battery,org.kde.plasma.bluetooth,org.kde.plasma.clipboard,org.kde.plasma.devicenotifier,org.kde.plasma.keyboardindicator,org.kde.plasma.keyboardlayout,org.kde.plasma.manage-inputmethod,org.kde.plasma.mediacontroller,org.kde.plasma.networkmanagement,org.kde.plasma.nightcolorcontrol,org.kde.plasma.notifications,org.kde.plasma.volume
knownItems=org.kde.kdeconnect,org.kde.kscreen,org.kde.plasma.battery,org.kde.plasma.bluetooth,org.kde.plasma.clipboard,org.kde.plasma.devicenotifier,org.kde.plasma.keyboardindicator,org.kde.plasma.keyboardlayout,org.kde.plasma.manage-inputmethod,org.kde.plasma.mediacontroller,org.kde.plasma.networkmanagement,org.kde.plasma.nightcolorcontrol,org.kde.plasma.notifications,org.kde.plasma.volume
scaleIconsToFit=true
shownItems=org.kde.plasma.volume,org.kde.plasma.battery

Notice the last 2 lines. These are the ones I need to set in this exact [Containments][10][General] group.

When using the following code in layout.js:

var systray = panel.addWidget("org.kde.plasma.systemtray")
systray.currentConfigGroup = ["General"]
systray.writeConfig("scaleIconsToFit", true)
systray.writeConfig("shownItems" , "org.kde.plasma.volume,org.kde.plasma.battery")

Those 2 lines are set in a new independent group elsewhere in the appletsrc file:

[Containments][28][Applets][36][Configuration][General]
scaleIconsToFit=true
shownItems=org.kde.plasma.volume,org.kde.plasma.battery

When using the following code in layout.js:

var systray = panel.addWidget("org.kde.plasma.systemtray")
systray.writeConfig("scaleIconsToFit", true)
systray.writeConfig("shownItems" , "org.kde.plasma.volume,org.kde.plasma.battery")

Those 2 lines are also set in a new independent group elsewhere in the appletsrc file:

[Containments][1][Applets][9][Configuration]
PreloadWeight=55
SystrayContainmentId=10
scaleIconsToFit=true
shownItems=org.kde.plasma.volume,org.kde.plasma.battery

I can’t get rid of the [Applets] group.
I tried other ways/variants but I cannot write in the group [Containments][10][General].

Any idea what else to try?
Thank you very much, guys!