summaryrefslogtreecommitdiff
path: root/widgets/battery.lua
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/battery.lua')
-rw-r--r--widgets/battery.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/widgets/battery.lua b/widgets/battery.lua
new file mode 100644
index 0000000..f6e6860
--- /dev/null
+++ b/widgets/battery.lua
@@ -0,0 +1,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