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, but
instead one of the child processes. You'd have to walk the entire process
hierarchy. And that can go wrong, if processes end up getting orphaned.
You'd ideally use control groups to do this correctly, but I suspect
systemd would get into the way.

Maybe, instead of stopping, you could just re-nice the application. That
would be less invasive.

Realistically though, Linux is already pretty damn good about prioritizing
applications. So, I suspect you won't see as much of a benefit as what you
are hoping for.


Markus

On Sun, Jul 17, 2016 at 1:01 PM, lexa fedotov <l...@cfotr.com> wrote:

> 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:connect_signal("unfocus", function () signal.kill(c.pid,
> signal.SIGSTOP); end);
>          c:connect_signal("focus", function () signal.kill(c.pid,
> signal.SIGCONT); end);
>     end}
>     }
>
> I'm not sure that automatic process suspension will play nicely with
> all applications, but you could try and see for yourself.
>
> On 7/17/16, Sebastian Fischmeister <sfisc...@uwaterloo.ca> wrote:
> > 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 firefox, awesome should send SIGSTOP
> > to the firefox process. When I focus on firefox again, awesome should
> > send a SIGCONT.
> >
> > Candidates for this behaviour includes browsers in general, but also
> > virtualbox, and even some messenger apps (I get the notification on my
> > cell phone anyways).
> >
> > Any ideas?
> >
> >   Sebastian
> >
> > --
> > To unsubscribe, send mail to awesome-unsubscr...@naquadah.org.
> >
>
>
> --
> Kind Regards,
> Aleksey
>
> --
> To unsubscribe, send mail to awesome-unsubscr...@naquadah.org.
>

Reply via email to