Automatic process suspension upon unfocus

2016-07-17 Thread Sebastian Fischmeister
Hi, There are a lot of apps who consume cpu time in the background while I'm not using them. Does anyone know a good way to incorporate automatic process suspension upon unfocus to awesome? For example, I have gmail open in a dedicated browser (e.g., I only use firefox for this). When I unfocus f

Re: Automatic process suspension upon unfocus

2016-07-17 Thread lexa fedotov
Hi Sebastian, I can propose a way to automatically suspend/unsuspend application when it loses/regains its focus. Please take a look at this snippet. local signal = require("posix.signal") awful.rules.rules = { { rule = { class = "Firefox" }, callback = function(c) c:conn

Re: Automatic process suspension upon unfocus

2016-07-17 Thread Markus Gutschke
I am sure this has all sorts of unintended consequences. For instance, when you suspend an X application, it can't redraw the screen. But there are definitely events that cause redraws without giving focus to the application. Also, often it isn't the top-level process that is chewing up the CPU,

Re: Automatic process suspension upon unfocus

2016-07-17 Thread Sebastian Fischmeister
The example from Aleksey works pretty well. For example, Slack for Linux is just a resource hog as it constantly polls whether new messages have arrived. Since it's a crappy implementation, the Linux scheduler cannot do anything about it. But that little extension can do wonders! However, I agree,

Re: Automatic process suspension upon unfocus

2016-07-17 Thread Aleksei Fedotov
>Finally using the terminal pkill instead of signal.kill() would be nice, > as it could send SIGSTOP to all child processes. I think that the best solution would be exploiting control groups, as Markus suggested. They can automatically account for all child processes and you can limit CPU consump