summaryrefslogtreecommitdiff
path: root/widgets/battery.lua
blob: f6e68607a792dcac21e05c069e08b5950479fac1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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