1 local wibox = require("wibox")
2 local vicious = require("vicious")
3 local naughty = require("naughty")
4 local beautiful = require("beautiful")
7 -- Battery (based on https://bitbucket.org/skrattaren/awesome/src/)
9 local limits = { {25, 5},
14 local function getnextlim (num)
15 for ind, pair in pairs(limits) do
16 lim = pair[1]; step = pair[2]; nextlim = limits[ind+1][1] or 0
29 local function batclosure ()
30 local nextlim = limits[1][1]
31 return function (_, args)
32 local state, charge = args[1], args[2]
33 if not charge then return end
36 if charge <= nextlim then
37 naughty.notify({title = "⚡ Warning! ⚡",
38 text = "Battery has leaked most of its power ( ⚡ "..charge.."%)!",
40 position = "top_right",
41 fg = beautiful.fg_focus,
42 bg = beautiful.bg_focus
44 nextlim = getnextlim(charge)
46 elseif state == "+" then
48 nextlim = limits[1][1]
52 if dir ~= 0 then charge = charge.."%" end
53 return " "..dirsign..charge..dirsign.." "
57 batterywidget = wibox.widget.textbox()
58 vicious.register(batterywidget, vicious.widgets.bat, batclosure(), 5, "BAT0")