How to change settings through command line

I want to change the idle delay before turning off the screen based on certain circumstances. I thus need to do so in a script.

I found that I can do eg.
/usr/bin/kwriteconfig5 --file powermanagementprofilesrc --group AC --group DPMSControl --key idleTime 30.

This does update the setting (the change is reflected in Plasma Settings GUI), but, as stated in the help of kwriteconfig5, does not apply it immediately, it only changes the config file.

How can I change make the change taken into account, like when you click Apply in the GUI ? With DBUS ? But how ?

Try qdbus6 org.freedesktop.PowerManagement /org/kde/Solid/PowerManagement org.kde.Solid.PowerManagement.refreshStatus

The qdbus executable might have a different name depending on your distribution.

1 Like

You’re on the right track with /usr/bin/kwriteconfig5 --file powermanagementprofilesrc --group AC --group DPMSControl --key idleTime 30 , but to APPLY, you need:

qdbus org.freedesktop.PowerManagement /org/kde/Solid/PowerManagement org.kde.Solid.PowerManagement.refreshStatus

So try putting both commands in a script…