API Scripting - Set Panel property in layout.js of Global Theme

Hello,

With Plasma 6 I try to set the new Panel property Fit Content through API scripting.

The feature does not exist yet in 6.0 (478489) but apparently I could set it anyway through a different method, by writting into its config file.

I have no skill in C++ nor QML.
I read API documentation | Developer and here’s what I understand:

  • I need to open the config file
  • I need to switch to the Group
  • Write the entry with string key and value

The end result is in ~/.config/plasmashellrc there should have a line with panelLengthMode = 1 under [PlasmaViews][Panel nnn] section, where “nnn” is a number.

I have tried various possibilities but I know I don’t understand how to get there.

This is what I have in my layout.js at the moment:

// 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”

const panel = ConfigFile(‘plasmashellrc’)
panel.group = ‘PlasmaViews’
panel.writeConfig(‘panelLengthMode’, 1)

I would like to understand why I am missing.
There are 3 similar properties I am trying to set in applets/panel/right-clickMenu, maybe if I understand one I can then move on by myself with the other 2. Those are also here on the Forum dated March 2023 from Plasma 5.

Thanks