Plasma API Scripting - Set Mouse Actions Right-Button 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 have already opened another thread for the other question.

In this thread it will be about setting configuration properties for Plasma Desktop Context Menu (mouse actions).

I have read many documentations (a few here below) and still fail to apply that change. 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 the property that would get set when the user selects the Global Theme:

  1. Display the Leave command options when right-clicking mouse on the wallpaper to call the context menu (mouse actions/right-button)

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 context menu 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 look like this, in the below groups, in ~/.config/plasma-org.kde.plasma.desktop-appletsrc:

[ActionPlugins][0][RightButton;NoModifier]
_logout=true

However I noticed when manually setting that option Plasma in fact writes a bunch of other things that may be “dependencies” or something. So it actually looks like this:

[ActionPlugins][0][RightButton;NoModifier]
_add panel=true
_context=true
_display_settings=true
_lock_screen=false
_logout=true
_open_terminal=false
_run_command=false
_sep1=true
_sep2=true
_sep3=true
_wallpaper=true
add widgets=true
configure=true
configure shortcuts=false
edit mode=true
manage activities=true
remove=true

So I think I have to write all of the above in order to work.

When using the following code in layout.js:

var logout = desktop.wallpaperPlugin("org.kde.contextmenu")
logout.currentConfigGroup = Array("ActionPlugins", "RightButton;NoModifier")
logout.writeConfig("_logout", true)

It deletes 95% of the lines in appletsrc file.

When using the following code in layout.js:

const logout = ConfigFile('plasma-org.kde.plasma.desktop-appletsrc');
logout.group = 'ActionPlugins';
logout.writeEntry('_logout', true);

I get 3 seperate groups in the appletsrc file:

[ActionPlugins]
_logout=true

[ActionPlugins][0]
MiddleButton;NoModifier=org.kde.paste
RightButton;NoModifier=org.kde.contextmenu
wheel:Vertical;NoModifier=org.kde.switchdesktop

[ActionPlugins][1]
RightButton;NoModifier=org.kde.contextmenu

When using the following code:

let desktop = desktops()[0]
desktop.ActionPlugins = "org.kde.contextmenu"
desktop.currentConfigGroup = ("ActionPlugins")
desktop.writeConfig("_logout", true)

I get the following result:

[Containments][2][ActionPlugins]
_logout=true

I tried other ways/variants but I cannot write in the group [ActionPlugins][0][RightButton;NoModifier].

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