2

The Problem

What I'm looking for is what's needed to change the state of the "Screen Energy Saving" setting in KDE from the command line.

Currently I do this graphically in one of two ways:

  • System Settings -> Power Management -> Energy Saving -> Screen Energy Saving
  • Battery and Brightness Widget -> Enable Power Management

I currently run a custom daemon for switching my workstation between a Desktop and TV context (this means changing the monitor resolution and primary monitor), and would like to be able to hook into toggling the "Screen Energy Saving" setting as well, as I often find I forget to change the setting from the widget toggle when switching contexts back.

What I Tried

I searched through my ~/.config directory with the following grep:

grep -rnis -e "power" -e "energy" -e "saving" ~/.config/{k,plasma}*

I was looking for any instance of the word "power", "energy", or "saving" in what appears to be anything related to KDE or Plasma specifically.

I get the following hits, but nothing that changes when I toggle the "Screen Energy Saving" setting.

/home/joe/.config/kglobalshortcutsrc:290:[org_kde_powerdevil]
/home/joe/.config/kglobalshortcutsrc:296:PowerOff=Power Off,Power Off,Power Off
/home/joe/.config/kglobalshortcutsrc:299:_k_friendly_name=Power Management
/home/joe/.config/ksmserverrc:30:program4=/usr/lib/x86_64-linux-gnu/libexec/org_kde_powerdevil
/home/joe/.config/ksmserverrc:38:restartCommand4=/usr/lib/x86_64-linux-gnu/libexec/org_kde_powerdevil,-session,<uuid>
/home/joe/.config/plasmashellrc:40:pluginWhiteList=services,desktopsessions,PowerDevil,shell,bookmarks,baloosearch,locations

Is this something that's actually managed by KDE? Or is KDE just offloading this call to PowerDevil potentially?

For Reference

  • KDE Plasma Version: 5.12.9
  • KDE Frameworks Version 5.47.0

2 Answers 2

1

Another solution I found was editing $HOME/.config/powermanagementprofilesrc. Remove

[AC][DPMSControl]
idleTime=600

I did it with sed this way

sed -i "/\[AC\]\[DPMSControl\]/,+2d" $HOME/.config/powermanagementprofilesrc

then call qdbus org.freedesktop.PowerManagement /org/kde/Solid/PowerManagement org.kde.Solid.PowerManagement.reparseConfiguration to reload config

If you need to reactivate it add the lines again and run qdbus with the same parameters

1
  • 3
    An even nicer solution cause there are tools for editing and reloading KDE config files. kwriteconfig5 --file $HOME/.config/powermanagementprofilesrc --group AC --group DPMSControl --key idleTime --type int 0 then call qdbus org.kde.Solid.PowerManagement /org/kde/Solid/PowerManagement org.kde.Solid.PowerManagement.refreshStatus to refresh the config. If you need to reactivate it, change int value to seconds for idletime and call qdbus refresh again
    – Jackfritt
    Commented May 11, 2023 at 16:57
1

For anyone coming across this I figured it out, but it wasn't anywhere near where I expected it to be. This can manually be controlled via a qdbus call.

To suspend "Screen Energy Saving":

dbus-send --print-reply \
--dest=org.freedesktop.PowerManagement.Inhibit \
/org/freedesktop/PowerManagement/Inhibit \
org.freedesktop.PowerManagement.Inhibit.Inhibit \
string:"Application Name" \
string:"Reason"

which will give a reply like

method return time=1592250463.638616 sender=:1.54 -> destination=:1.574 serial=4527 reply_serial=2
   uint32 <id>

This uint32 <id> is what we need to re-enable this setting, which can be called as such:

dbus-send \
--dest=org.freedesktop.PowerManagement.Inhibit \
/org/freedesktop/PowerManagement/Inhibit \
org.freedesktop.PowerManagement.Inhibit.UnInhibit \
uint32:<id>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .