Reply to topic

command line to enable/disable automatic suspend

novazur
Registered Member
Posts
23
Karma
0
OS
Hi,

First, sorry for my poor English...

In power settings, I can enable automatic suspend after 10mn (or other time).
I'd like to be able to disable (and enable again) this automatic suspend by command line.

Someone knows how to do that please ?

NB : I don't want to suspend by command line, I already know how to do that... I just want to disable the setting of automatic suspend.

Thanks.
User avatar bcooksley
Administrator
Posts
18614
Karma
83
OS
This could be rather difficult. Do you still need all other forms of power management enabled?


System Settings and Device Actions KCM maintainer
Image
novazur
Registered Member
Posts
23
Karma
0
OS
Yes.
I don't need them on my desktop, but I need them on laptops.
User avatar bcooksley
Administrator
Posts
18614
Karma
83
OS
Okay, in this case there are no explicit command lines you can run. However, there are two files which can be altered, and a command which can be run - which will have the result of allowing you to enable/disable automatic suspend.
Code: Select all
~/.kde4/share/config/powermanagementprofilesrc
~/.kde4/share/config/powerdevilrc

The file most likely to need modification is powermanagementprofilesrc.

After modifying the file(s) in question you need to run this command to cause KDE to reload it's power management rules:
Code: Select all
qdbus org.kde.kded /org/kde/Solid/PowerManagement reparseConfiguration


The other alternative you could do is write a small script which creates a power management inhibition, and then exits when you instruct it to.
KDE's Power Management system follows the FDO specification here, so i'd suggest referring to their documentation on this.


System Settings and Device Actions KCM maintainer
Image
novazur
Registered Member
Posts
23
Karma
0
OS
Perfect.
I'll try that.
Thank you very much.
novazur
Registered Member
Posts
23
Karma
0
OS
In fact, it doesn't work.

I modify .kde4/share/config/powermanagementprofilesrc, it's exactly as it is when I modify it by settings menu.
I launch /usr/bin/qdbus org.kde.kded /org/kde/Solid/PowerManagement reparseConfiguration, but after 15mn, suspend is done.
Are you sure that's the good command to "reload" settings ?

I use kde 4.11.2.

Hee is my script :
Code: Select all
#!/bin/bash
cd ~/.kde4/share/config/
if $(grep -q "\[AC\]\[SuspendSession\]" powermanagementprofilesrc) ; then
        ed -s powermanagementprofilesrc <<FOOBAR
/\[AC\]\[SuspendSession\]/-1,/suspendType=1/d
wq
FOOBAR

else
        sed -i '/idleTime=[0-9]*/a\\n[AC][SuspendSession]\nidleTime=900000\nsuspendType=1' powermanagementprofilesrc
fi
/usr/bin/qdbus org.kde.kded /org/kde/Solid/PowerManagement reparseConfiguration
User avatar bcooksley
Administrator
Posts
18614
Karma
83
OS
Yes, that should be the correct command - it is the exact same one used by the configuration panel.
Your script is running under your normal user account correct?


System Settings and Device Actions KCM maintainer
Image
novazur
Registered Member
Posts
23
Karma
0
OS
bcooksley wrote:Your script is running under your normal user account correct?

Yes.
luebking
Registered Member
Posts
924
Karma
7
inhibit_cookie=`qdbus org.freedesktop.PowerManagement.Inhibit /org/freedesktop/PowerManagement/Inhibit Inhibit "Me" "I am your god"`
qdbus org.freedesktop.PowerManagement.Inhibit /org/freedesktop/PowerManagement/Inhibit Uninhibit $inhibit_cookie

you likely want to store the cookie in some file to read it later on (and use as lockfile)
novazur
Registered Member
Posts
23
Karma
0
OS
luebking wrote:inhibit_cookie=`qdbus org.freedesktop.PowerManagement.Inhibit /org/freedesktop/PowerManagement/Inhibit Inhibit "Me" "I am your god"`
qdbus org.freedesktop.PowerManagement.Inhibit /org/freedesktop/PowerManagement/Inhibit Uninhibit $inhibit_cookie

you likely want to store the cookie in some file to read it later on (and use as lockfile)


...hmmm... can you explain what it does please ?
Those 2 lines disable automatic suspend only (not screen savepower) ?
If yes, how to enable it again after ?
If no, that's not what I asked ;)
luebking
Registered Member
Posts
924
Karma
7
1st off, there's a typo: "UnInhibit", not "Uninhibit"

The first line is supposed to prevent stuff like suspending and screen locking, but not screen dimming (dunno at hand about "dpms off")
The second line will UnInhibt power saving.

There's however claim this would not work for stuff like qdbus/dbus-send but only for eg. python-dbus and likely cpp interfaces - i assume the power manager checks the caller PID.

I can also confirm that reparsing the config does not appear to happen.

Only resort to suggest is to unload powerdevil:

qdbus org.kde.kded /kded unloadModule powerdevil
xset dpms 360 480 480
xset +dpms # do dpms the xorg way

And reload it afterwards:
qdbus org.kde.kded /kded loadModule powerdevil

Notice that any other user or service can still kick in and STR, it's basically just writing a string into /sys/power/state
novazur
Registered Member
Posts
23
Karma
0
OS
I need to use google translate to understand all, but by advance, thanks for your help ;)
novazur
Registered Member
Posts
23
Karma
0
OS
luebking wrote:Only resort to suggest is to unload powerdevil:


You point something I don't understand.
I have and need powerdevil to be able to configure suspend. If I don't emerge powerdevil, I don't have power settings (energy management) in the menu.
But I realize, it disables dpms.
But, if I unload powerdevil module, the settings choices are différents... therefore I can enable suspend.
So, why do I need powerdevil package ? Or, why do I need powerdevil module loaded ? If the module is unloaded, even if I can set suspend time, it will never suspend ?
If I could have dpms enabled (as several months ago), I wouldn't have to set it in the power setting AND I would have screen blanking even on kde session choice, not only when a user session is opened, so i'd prefer to have dpms working.

May be it's because my english is very bad, but all of this seems to be very difficult to understand for me.
And I need to understand that before finding the best solution to disable/enable automatic suspend.
novazur
Registered Member
Posts
23
Karma
0
OS
I can confirm that with powerdevil unloaded, no suspend.
So the solution unloading it to disable automatic suspend, then reloading it to enable can be what I need.
But, a question, in my script, what command can I use to test is powerdevil is loaded or not please ?
novazur
Registered Member
Posts
23
Karma
0
OS
novazur wrote:But, a question, in my script, what command can I use to test is powerdevil is loaded or not please ?

qdbus org.kde.kded /kded loadedModules | grep -q powerdevil ?

 
Reply to topic

Bookmarks



Who is online

Registered users: alake, anditosan, apater, Baidu [Spider], Bing [Bot], einar, Exabot [Bot], Google [Bot], google01103, koriun, La Ninje, lazyit, Majestic-12 [Bot], Mechatronic, mmistretta, paulus3005, pbCyanide, pedrorodriguez, random_fan, Robert Leleu, SeaJey, Sentynel, Sogatori, vascobasque, whatthefunk, Yahoo [Bot]