![]() Registered Member ![]()
|
Apologies if this has been discussed before, but I couldn't find it anywhere (although I suspect it's not an uncommon request). I'm looking for a way to change system settings from the command line, specifically Energy Saving (suspend) options. I'd like a script to be able to inhibit sleep. This is the equivalent to unchecking the "suspend session" box in the Energy Saving panels. (It'd also be great to change screensaver settings, too.)
Thanks in advance.
Last edited by sparhawk on Sun Dec 23, 2012 3:24 am, edited 3 times in total.
|
![]() Global Moderator ![]()
|
Good call.
I've seen a thread here and there but only the odd snippet. Be great if this could serve as a pool and perhaps even encourage some decent documentation. I'd be glad to add to the wiki ![]()
Debian testing
|
![]() ![]()
|
this alters the configuration files FOR THE AC PROFLE (there's also Battery and LowBattery or similar) and sets the timeout to a day (deactivation deletes the key, but that's not possible with kwriteconfig)
will reconfigure the ded, but i've no idea whether that implicitly reconfigured all modules as well. However, if you actually want to (temporarily) block all powersavings (because the screen dims during a video presentation etc.) you might want to try
and later on
|
![]() Registered Member ![]()
|
Thanks again for the helpful reply, luebking.
It seems that the first suggestion doesn't work (for me), but the second suggestion does. It's not exactly what I asked for, but it does solve my problem perfectly. Thanks! Also, do you know if this is a global setting (i.e. for all users)? i.e. if I use this command as root from a udev script, will it prevent suspension for users too? Cheers. |
![]() ![]()
|
no, qdbus operates on the session bus, thus effectively "per user".
Also you have to export the correct DISPLAY variable (usually "DISPLAY=:0") However, the superuser can oc. feign to be any other user, ie. you put that stuff into a script and run it "sudo -u $USER powerToggle.sh" "users" is gonna tell you who's logged in, the rest ist BashFu =) |
![]() Registered Member ![]()
|
Excellent! Thanks. That does seem to work fine.
|
![]() Registered Member ![]()
|
A bit of an update: it seems that the scope of the power module is a bit greater than I realised. One of the reasons I want to stop the computer from suspending is to run long tasks, often overnight (for example, backing up, building something, processor-intensive jobs, etc.). I'd like to be able to reduce the screen brightness while preventing the computer from going to sleep, but it seems that disabling the power module also prevents reducing the brightness.
I can do `xset dpms force off`, but if someone bumps the mouse (for example), then the screen stays on all night. OTOH, in gnome I was able to use `gsettings` to set the screen to sleep at 1 second, while preventing the computer from suspending to RAM. |
![]() Administrator ![]()
|
Unfortunately Powerdevil is responsible for handling the turning off of the screen to the best of my knowledge after a certain amount of time.
Instead of unloading Powerdevil, does running the following cause it to reload it's configuration?
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
![]() Registered Member ![]()
|
Thanks for the reply. Unfortunately, it doesn't seem to work either. From luebking's suggestion above, it seems that an idleTime of 1000 is equivalent to 1 second. First, I tried to set the time to a minute via the GUI, and it worked with good precision. I quit system settings, then tried again with the following code, but nothing happened after a minute.
|
![]() ![]()
|
You don't need powerdevil to (automatically) sleep the screen nor in many cases to alter brightness.
For brightness just see whether xbacklight works (simpler than writing into the backlight device and does not require root permissions. There's also a "backlighthelper" tool in /usr/lib/kde4/libexec, but i don't know the paramters atm. For dpms control, check "xset -q" to see the current state. Then use eg "xset dpms 360 420 480; xset +dpms" to set dpms to standby after 6 minutes, suspend after 7 and off after 8 "xset +dpms" activates dpms, "xset -dpms" DEactivates it - you could also just power off the screen by hand btw. In doubt saves even more energy. From my experience every loading of powerdevil will simply disable X11 dpms, so you got to re-activate (and perhaps re-setup) it as well with this. |
![]() Registered Member ![]()
|
Great! xset is a good workaround.
Using xbacklight isn't really a great option, because if I set the brightness to 0 by hand, I'd have to type into a blank screen to reset it. I suppose I could assign it to a shortcut key, but I imagine xset probably turns the screen off "more". Also, it's a laptop, so I can't turn the screen off by hand. What's interesting is that I don't think reloading the powerdevil resets dpms.
From that, it seems that when I re-enabled powerdevil, now xset is also operational? ----EDIT (more testing) Okay, so I think I've got it partially figured out. It seems that dpms is the means by which KDE applies power-saving to the screen. Hence, if I unload/reload powerdevil, then dpms will turn off/on. In addition, I can manually turn dpms on/off using `xset +dpms` or `xset -dpms`. (While powerdevil is loaded) if I modify the KDE system settings (screen energy savings), it will turn on dpms if previously off. That all seems to make sense now. Essentially, the state of dpms is controlled by the powerdevil (and KDE system settings), although it can be controlled separately. The only strange thing is that if I load the KDE dpms settings (either through the GUI or reloading powerdevil), it sets the standby setting to whatever is in the GUI, but the suspend value to 150% of standby, and the off value to 200% of standby. From googling, there's probably no difference between the three states for my laptop lcd, but I did think it was a little odd. Thanks again! |
![]() Registered Member ![]()
|
Hmmm... One more question...
In order to keep my dpms settings consistent when unloading powerdevil, I'm trying to read KDE settings, by using kreadconfig. I cannot work out how to quote the name of the group. I've worked out that the --file is located in ~/.kde/share/config/ , but do not know how to refer to "[AC][DPMSControl]". For example, the following does not work.
I've noticed that previously in this thread, luebking suggested using
However, when I look at ~/.kde/share/config/powermanagementprofilesrc , I can now see two groups, "[AC][SuspendSession]" and "[AC/SuspendSession]". When I change KDE sleep settings via the GUI, the former changes. I wonder if the reason why none of our previous troubleshooting worked was that the latter did not refer to anything present previously, and we actually mis-quoted the name of the setting? |
![]() ![]()
|
Yes, and yes, my bad.
Use kreadconfig --file powermanagementprofilesrc --group AC --group DPMSControl --key idleTime |
![]() Registered Member ![]()
|
Ah thanks. Just for some more closure, I tested kwriteconfig again with both pairs of new settings, but neither worked. For good measure I tried both possible methods of reloading the configuration. That is, I tried
and
and neither worked after waiting a minute. Interestingly enough, after the first line in both cases (`kwriteconfig`), I could see the new settings when I opened up the KDE system settings GUI (in the first case rounded up to 1 minute). Anyway, this is just really FYI, since I have a perfectly functional workaround unloading powerdevil and re-enabling dpms (in fact, it's probably cleaner). Thanks again for all your help. |
Registered users: Baidu [Spider], Bing [Bot], Google [Bot]