]> git.rmz.io Git - dotfiles.git/blobdiff - awesome/widgets/mpd_widget.lua
awesome/mpd_widget: reset timeout when popup_hide is called again
[dotfiles.git] / awesome / widgets / mpd_widget.lua
index 2c6ab78ec3ce8888db1fbe4393a54de3a588958e..d96289355931432d011389bc9571daafc30520c4 100644 (file)
@@ -90,19 +90,27 @@ function widget:popup_show()
 end
 
 function widget:popup_hide(delay)
 end
 
 function widget:popup_hide(delay)
+    local function destroy()
+        if self._hover then return end
+        if not self._notification then return end
+        naughty.destroy(self._notification)
+        self._notification = nil
+    end
+
+    if not delay then
+        destroy()
+        return
+    end
+
     if self._hide_timer and self._hide_timer.started then
     if self._hide_timer and self._hide_timer.started then
+        self._hide_timer.timeout = delay
         self._hide_timer:again()
     else
         self._hide_timer = timer(
             { timeout = delay
             , autostart = true
             , single_shot = true
         self._hide_timer:again()
     else
         self._hide_timer = timer(
             { timeout = delay
             , autostart = true
             , single_shot = true
-            , callback = function()
-                if self._hover then return end
-                if not self._notification then return end
-                naughty.destroy(self._notification)
-                self._notification = nil
-                end
+            , callback = destroy
             })
     end
 end
             })
     end
 end