Destroy the "low battery" notification if present

This avoids that multiple notifications pop up repeatedly on the screen, which
is pretty annoying.
This commit is contained in:
Stefano Mazzucco 2019-12-13 10:16:10 +00:00
parent 834530e200
commit 5fa1cf3c25
1 changed files with 8 additions and 1 deletions

View File

@ -39,6 +39,7 @@ end
local icon_size = 64 local icon_size = 64
local icon_flags = {IconLookupFlags.GENERIC_FALLBACK} local icon_flags = {IconLookupFlags.GENERIC_FALLBACK}
local notification = nil
local widget = wibox.widget { local widget = wibox.widget {
resize = true, resize = true,
@ -81,8 +82,14 @@ function widget:_maybe_warn()
if should_warn then if should_warn then
local msg = (warning_level.name == "None" and "Low" or warning_level.name) .. " battery!" local msg = (warning_level.name == "None" and "Low" or warning_level.name) .. " battery!"
if notification then
naughty.destroy(
notification,
naughty.notificationClosedReason.dismissedByCommand
)
end
naughty.notify({ notification = naughty.notify({
preset = naughty.config.presets.critical, preset = naughty.config.presets.critical,
title = msg, title = msg,
text = percentage .. "% remaining"}) text = percentage .. "% remaining"})