From: Samir Benmendil Date: Tue, 19 Jan 2021 00:01:44 +0000 (+0000) Subject: awesome/mpc: don't show popup when not connected X-Git-Url: https://git.rmz.io/dotfiles.git/commitdiff_plain/df9d7973469d1dfc4ab0a909a01827f8a8844c3e?ds=sidebyside awesome/mpc: don't show popup when not connected --- diff --git a/awesome/widgets/mpd_widget.lua b/awesome/widgets/mpd_widget.lua index 2e4b215..0c794cd 100644 --- a/awesome/widgets/mpd_widget.lua +++ b/awesome/widgets/mpd_widget.lua @@ -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