XFCE (or related) Power Management "Inactivity" Settings/Exceptions
I'm looking for a way to setup the XFCE Power Management (or some other Power Management software that XFCE will honour) "inactivity" status so that it does not go to sleep when a certain operation or application is running.
Examples: I don't want the PC to go to sleep when I am:
- Downloading messages with Claws-Mail;
- Downloading torrents with Deluge;
- Doing a system scan with ClamAV;
- Doing a 'fsck -c" ...
You get the picture...
Some non-GUI software that any GUI (XFCE or any other DE) will honour would actually be preferred - but I'm ok with configuring XFCE directly (through some config file...? )
I would also prefer it to be tailored to operations (such as continuous network or disk activity) rather than applications, but again, configuring the (in)activity status based on apps will be fine too.
Thanks in advance.
I'm not entirely sure if you're okay with checking if the programs are running.
Monotoring if there is a network or disk activity is rather difficult. You had to grab (grep, awk, cut, sed), calculate (bc?) it and integrate the output in a script. Disks can be watched by iotop (--batch and --only options should do the trick). There are several tools to check the network but I unfortunaley only know nethogs that combines this with applications (all else do protocols and ports). It's also quite power-hungry if no delay (-d) is set.
On the other hand aren't mails steadily downloaded, isn't your bittorrent client always uploading?
The script below will only check if a program is running with pgrep. "clam" would also suffice for "clamav", just as "fsck" is enough for "fsck.ext4". You can set as many programs as you want but don't forget the double pipe "||" for OR. The xfconf command works with minutes: 15 is minimum, 350 is maximum. 0-14 means the system will never go to sleep. The sleep command is in seconds which you could technically set to your minimum inactivity time (900).
In only checked with
So the script will check once a minute if this or that program is running. If yes it will set the delay to 5:50 hours, if not it will set it to 0:15 hours.
man xfce4-power-manager says that applications can send an Inhibit to DBus so the system will not go to sleep. So a proper programmed program should do what you want (or at least offer as an option).
Thank you very much, äxl! That sounds like it will do it just fine, yes.
I understand (vaguely) he issues with monitoring disk/network activity (just asked in case...). So yes, monitoring programs instead will work just fine.
I was actually considering the use of cpufreqd (which was an absolute must on my old machine but not so much on this one) which provides similar functionality. But that seemed like a sort of dirty-hack to me (considering I would be using a cpufreqd's feature that was meant as an exception to cpu frequencies configurations, not directly to power management (though cpufreqd can be used in that respect quite well too).
So yes, the sollution you proposed looks much more straightforward and elegant! I'll try it out and report back later.
Following äxl's suggestions, I expanded a tiny bit on his script and came up with three scripts I can use to easilly manage the inactivity settings of XFCE4 Power Management app.
Sorry if the comments on them sound a bit quaint; I just like to keep things documented in case I stumble upon them later on and don't remember what they do or how anymore...
First script is basically äxl's script expanded a bit. I does not check for Network apps (Claws-Mail, Deluge ...). It will terminate the second script (posted bellow) if that one is running. And the second will payback the deed everytime too... First script:
I'm pretty sure these scripts with the ocasional tweaking will be plenty enough for a good while so I'm marking this as "solved".
Once again, many thanks, äxl, you did all the work, I only made some cosmetics! Thanks! :)
The above scripts DO NOT WORK!
They did detect whether the concerning applications were running or not and did execute the corresponding actions.
They did disable the sleep feature whenever the "/xfce4-power-manager/inactivity-on-ac" property value was set to 0.
But they did NOT bring the automatic go-to-sleep after n minutes of inactivity feature back up! Once disabled (set to 0), the auto-sleep would not be enabled again until reboot (or maybe relog)!
Oddly enough, my powman-dab-status script would report the property reset to 20 minutes and so would executing xfconf-query -c xfce4-power-manager -p "/xfce4-power-manager/inactivity-on-ac" -v directly on the terminal.
BUT the XFCE Power Manager settings GUI would display it as "never"! And this was what was actually happening on the system (it never went to sleep once it got disabled by my script at least once).
So I did three changes related to this (actually four but kept only three):
1. Set a condition to check whether the concerning property was set to auto-sleep or deactivated. I hadn't looked at the GUI yet and it had occured to me the resetting of the value might reset the inactivity count (thus the machine being reset to active every three minutes). It didn't fix it and I think this doesn't actually happen, but I kept it anyway for safe measure.
2. Removed the "-t string" part of the attribute-setting command. It's not needed and it should probably rather be set to "integer" or "number" or whatever. Didn't fix it either but still kept it.
3. Added a xfce-power-manager --restart after setting the property. Didn't fix it and I think it wiser to not keep it - this is the one that got removed.
4. Changed the disabling value from 0 to 14. I think this is what actually fixed it!
I haven't thoroughly tested it yet but it seems to be working.
The new versions of the scripts are pasted below and also include some additional applications not included before. Do note the case of dd which I had to set as pgrep -lf /bin/dd because "dd" is just too short (part of the name of other unrelated processes).
Same as in previous post, unchanged.
Improved the scripts.
The checking for a relevant running program is now done in the same way (with the necessarya adaptations) Jack S. Lai coded his own "Disable KDE4 screensaver while watching a movie" script, posted at http://www.linuxquestions.org/questi...0/#post4997687 . This is IMHO a much more deficient way of doing it.
The current powman-dab-nna script:
|All times are GMT -5. The time now is 12:57 AM.|