]> git.rmz.io Git - dotfiles.git/commitdiff
awesome/mpc: don't show popup when not connected
authorSamir Benmendil <me@rmz.io>
Tue, 19 Jan 2021 00:01:44 +0000 (00:01 +0000)
committerSamir Benmendil <me@rmz.io>
Sun, 24 Jan 2021 21:35:32 +0000 (21:35 +0000)
awesome/widgets/mpd_widget.lua

index 2e4b215a0ad5ccf9989075c2e290f816f5f5bd8a..0c794cd3aeb20edd64cbc50453073f5ced573404 100644 (file)
@@ -60,8 +60,10 @@ function widget:get_albumart()
 end
 
 function widget:get_info()
-    local info = {}
     local status, song = self._status, self._currentsong
+    if not status.state then return nil end
+
+    local info = {}
     info.title = status.state .. " " .. status.song .. "/" .. status.playlistlength .. " " .. song_duration(status.elapsed, status.duration)
     if not song.artist then
         info.text = string.format("%s", song.title or song.file)
@@ -77,7 +79,10 @@ end
 
 function widget:popup_show()
     if self._notification then return end
+
     local table = self:get_info()
+    if not table then return end
+
     self._timer:start()
     self._notification = naughty.notify(
         { title = table.title