+-- from https://blog.mister-muffin.de/2014/11/07/automatically-suspending-cpu-hungry-applications/
+--client.add_signal("focus", function(c)
+-- if c.class == "Firefox" or c.class == "chromium" or c.class == "Icedove" then
+-- awful.util.spawn("kill -CONT " .. c.pid)
+-- end
+--end)
+--local capi = { timer = timer }
+--client.add_signal("unfocus", function(c)
+-- local timer_stop = capi.timer { timeout = 120 }
+-- if c.class == "Firefox" or c.class == "chromium" or c.class == "Icedove" then
+-- 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()
+ local f = io.popen('acpi -b', 'r')
+ if not f then
+ return "acpi -b failed"
+ end
+
+ local s = f:read('*l')
+ f:close()
+ if not s then
+ return '-';
+ end
+
+ -- Battery 0: Discharging, 89%, 00:02:14 remaining
+ -- Battery 0: Charging, 58%, 00:02:14 until charged
+ -- Battery 0: Full, 100%
+ -- so find the first bit first and then go look for the time
+ local st, en, status, percent = string.find(s, '%a+%s%d:%s(%a+),%s(%d+%%)');
+ local st, en, time = string.find(s, ',%s(%d+:%d+):%d+%s%a+', en);
+
+ if not status or not percent then -- time can be empty if we're full
+ return "couldn't parse line " .. s
+ end
+
+ if not time then
+ return percent
+ end
+
+ if status == 'Charging' then
+ return '↑ ' .. percent;
+ elseif status == 'Discharging' then
+ return '↓ '.. time;
+ else
+ return '';
+ end
+end
+--t = timer({ timeout = 20 })
+--t:add_signal('timeout', hook_battery)
+--t:start()
+--hook_battery()
+--bashets.register_lua(mybatterybox, get_acpibatt, '%1', 30)
+--bashets.start()
+-- }}}