From 51da084705fe51d2c877c0f8ccd65ff4992e4ae7 Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Thu, 10 Mar 2016 11:13:11 +0100 Subject: [PATCH] suspend apps without focus --- .config/awesome/rc.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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() -- 2.39.5