diff --git a/pulseaudio_widget.lua b/pulseaudio_widget.lua index 22302c2..71eaf92 100644 --- a/pulseaudio_widget.lua +++ b/pulseaudio_widget.lua @@ -67,9 +67,15 @@ function widget:update_appearance(v) end -function widget.notify(v) +function widget:notify(v) local msg = tonumber(v) and string.format("%d%%", v) or v - naughty.notify({text=msg, timeout=1}) + + if self.notification then + naughty.destroy(self.notification, naughty.notificationClosedReason.dismissedByCommand) + end + + self.notification = naughty.notify({text=msg, timeout=1}) + end function widget:update_sink(object_path) @@ -140,7 +146,7 @@ function widget:connect_device(device) local v = math.ceil(tonumber(volume[1]) / this.BaseVolume * 100) if this.object_path == self.sink.object_path then self:update_appearance(v) - self.notify(v) + self:notify(v) end end, "VolumeUpdated" @@ -153,7 +159,7 @@ function widget:connect_device(device) local m = is_mute and "Muted" or "Unmuted" if this.object_path == self.sink.object_path then self:update_appearance(m) - self.notify(m) + self:notify(m) end end, "MuteUpdated"