]> git.rmz.io Git - dotfiles.git/commitdiff
awesome: added robustness when there's no current song
authorSamir Benmendil <me@rmz.io>
Mon, 22 Aug 2022 10:37:21 +0000 (11:37 +0100)
committerSamir Benmendil <me@rmz.io>
Mon, 22 Aug 2022 10:37:21 +0000 (11:37 +0100)
awesome/widgets/mpd_widget.lua

index 9a698f76cabf62784b304152a535768c0a7934d7..89deae19af6fbc7c363a11008120559c0b8c6874 100644 (file)
@@ -64,6 +64,7 @@ end
 function widget:get_info()
     local status, song = self._status, self._currentsong
     if not status.state then return nil end
 function widget:get_info()
     local status, song = self._status, self._currentsong
     if not status.state then return nil end
+    if not status.song then return nil end
 
     local info = {}
     info.title = status.state .. " " .. status.song .. "/" .. status.playlistlength .. " " .. song_duration(status.elapsed, status.duration)
 
     local info = {}
     info.title = status.state .. " " .. status.song .. "/" .. status.playlistlength .. " " .. song_duration(status.elapsed, status.duration)
@@ -166,6 +167,10 @@ function widget:run()
 
                 conn:send("currentsong", function(_, song)
                     self._currentsong = song
 
                 conn:send("currentsong", function(_, song)
                     self._currentsong = song
+                    if not song then
+                        self:update_widget()
+                        return
+                    end
                     conn:albumart(song.file, function(_, art)
                         self._albumart = art
                         self:update_widget()
                     conn:albumart(song.file, function(_, art)
                         self._albumart = art
                         self:update_widget()