From: martin f. krafft Date: Thu, 10 Mar 2016 10:13:11 +0000 (+0100) Subject: suspend apps without focus X-Git-Url: https://git.madduck.net/etc/awesome.git/commitdiff_plain/51da084705fe51d2c877c0f8ccd65ff4992e4ae7?hp=9bed174f669ab4dabc460f748e5325e37bc406a7 suspend apps without focus --- diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index e630208..18209c0 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -576,6 +576,27 @@ function hook_battery() end -- }}} +-- from https://blog.mister-muffin.de/2014/11/07/automatically-suspending-cpu-hungry-applications/ +client.add_signal("focus", function(c) + if c.class == "Iceweasel" or c.class == "chromium" or c.class == "Icedove" then + awful.util.spawn("kill -CONT " .. c.pid) + end +end) +client.add_signal("unfocus", function(c) + local capi = { timer = timer } + if c.class == "Iceweasel" or c.class == "chromium" or c.class == "Icedove" then + local timer_stop = capi.timer { timeout = 10 } + local send_sigstop = function () + timer_stop:stop() + if client.focus.pid ~= c.pid then + awful.util.spawn("kill -STOP " .. c.pid) + end + end + timer_stop:add_signal("timeout", send_sigstop) + timer_stop:start() + end +end) + -- {{{ Statusbar battery -- function get_acpibatt()