local awful = require("awful") local wibox = require("wibox") local naughty = require("naughty") local widget = wibox.widget.textbox() -- update widget on lowbat output local lowbat_pid = awful.spawn.with_line_callback("lowbat", { stdout = function(stdout) widget:set_text(stdout) end, stderr = function(stderr) naughty.notify({ preset = naughty.config.presets.critical, title = "lowbat error", text = stderr }) end, }) -- kill current lowbat on refresh/exit awesome.connect_signal("exit", function() awful.spawn("kill " .. lowbat_pid) end) return widget