Bug 463292

Summary: User configuration for KWin scripts is not applied until after disabling and reenabling the script
Product: [Applications] systemsettings Reporter: Natalie Clarius <natalie_clarius>
Component: kcm_kwinscriptsAssignee: KWin default assignee <kwin-bugs-null>
Status: CONFIRMED ---    
Severity: normal CC: alexander.lohnau, nate, nicolas.fella, plasma-bugs-null
Priority: NOR    
Version First Reported In: 5.26.4   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Natalie Clarius 2022-12-21 00:29:18 UTC
SUMMARY
***
Changed user settings for a KWin script do not take effect until after the script is disabled and enabled again.
***

STEPS TO REPRODUCE
1. Install a KWin script with user configuration, e.g. Window Gaps
2. Change settings via the configure button in the entry for the script, e.g. gap size
3. Click "Apply" in the configuration dialog

OBSERVED RESULT
Changes do not take effect; script must be disabled and reenabled first

EXPECTED RESULT
Changes take effect after hitting the "Apply" button

SYSTEM INFORMATION
Operating System: Arch Linux
KDE Plasma Version: 5.26.4
KDE Frameworks Version: 5.101.0
Qt Version: 5.15.7
Kernel Version: 6.0.10-arch2-1 (64-bit)
Graphics Platform: X11
Comment 1 Nicolas Fella 2022-12-21 12:56:13 UTC
There even is a TODO for this in the code: https://invent.kde.org/plasma/kwin/-/blob/master/src/scripting/genericscriptedconfig.cpp#L182
Comment 2 Nicolas Fella 2022-12-21 13:30:48 UTC
I wonder what the best approach for this is. A brute-force approach would be to automatically reload the script when saving the config. That wouldn't require changing the scripts. Or we do what we do for scripted effects, which is a "configChanged" signal that effects connect to and re-read the config: https://invent.kde.org/plasma/kwin/-/blob/master/src/effects/scale/package/contents/code/main.js#L23
Comment 3 Natalie Clarius 2022-12-21 19:35:23 UTC
I would think that a solution that also works for existing scripts would be preferable, but I don't know what the potential drawbacks of reloading the script would be.