X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/4664741483e8c395d4e042a91552925ab63e5130..68037080cd50887746db0529e20c4bd1f8c404d4:/widgets/contrib/tpbat/init.lua diff --git a/widgets/contrib/tpbat/init.lua b/widgets/contrib/tpbat/init.lua index 673b66c..1bb6a9b 100644 --- a/widgets/contrib/tpbat/init.lua +++ b/widgets/contrib/tpbat/init.lua @@ -30,7 +30,8 @@ local tpbat = { } local tpbat_notification = nil function tpbat:hide() - if tpbat_notification ~= nil then + if tpbat_notification ~= nil + then naughty.destroy(tpbat_notification) tpbat_notification = nil end @@ -49,8 +50,10 @@ function tpbat:show(t_out) local time = bat:remaining_time() local msg = "\t" - if status ~= "idle" and status ~= "nil" then - if time == "N/A" then + if status ~= "idle" and status ~= "nil" + then + if time == "N/A" + then msg = "...Calculating time remaining..." else msg = time .. (status == "charging" and " until charged" or " remaining") @@ -65,7 +68,7 @@ function tpbat:show(t_out) tpbat_notification = naughty.notify({ preset = { fg = beautiful.fg_normal }, text = str, - timeout = t_out + timeout = t_out }) end @@ -80,17 +83,18 @@ function tpbat.register(args) tpbat.widget = wibox.widget.textbox('') - if bat:get('state') == nil then - local n = naughty.notify({ - title = "SMAPI Battery Warning: Unable to read battery state!", - text = "This widget is intended for ThinkPads. Is tp_smapi installed? Check your configs & paths.", - position = "top_right", - timeout = 15, - fg="#202020", - bg="#cdcdcd", - ontop = true - }) - end + if bat:get('state') == nil + then + local n = naughty.notify({ + title = "SMAPI Battery Warning: Unable to read battery state!", + text = "This widget is intended for ThinkPads. Is tp_smapi installed? Check your configs & paths.", + position = "top_right", + timeout = 15, + fg="#202020", + bg="#cdcdcd", + ontop = true + }) + end function update() bat_now = {