diff options
author | Alexander Yakushev <yakushev.alex@gmail.com> | 2011-11-18 15:02:54 +0200 |
---|---|---|
committer | Alexander Yakushev <yakushev.alex@gmail.com> | 2011-11-18 15:02:54 +0200 |
commit | 544479fa37beaf77a4fb7eeb905be1dd3bacdd3b (patch) | |
tree | 01afbd546201dd4a3db0dfc264393a9b382965af | |
parent | 498f6aa0332f9ba274d7bbd361c77dc8b5dd2721 (diff) | |
download | awesompd-544479fa37beaf77a4fb7eeb905be1dd3bacdd3b.tar.gz awesompd-544479fa37beaf77a4fb7eeb905be1dd3bacdd3b.tar.bz2 |
Minor bugfix
When the widget was not connected to the server it tried to show
notification and failed because current_track contained no data.
-rw-r--r-- | awesompd.lua | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/awesompd.lua b/awesompd.lua index 417a51c..617d9cf 100644 --- a/awesompd.lua +++ b/awesompd.lua @@ -104,6 +104,12 @@ function awesompd.get_extended_info(track) return result end +-- Returns true if the current status is either PLAYING or PAUSED +function awesompd:playing_or_paused() + return self.status == awesompd.PLAYING + or self.status == awesompd.PAUSED +end + -- /// Helper functions /// -- Just like awful.util.pread, but takes an argument how to read like @@ -422,7 +428,7 @@ function awesompd:menu_playback() table.insert(new_menu, { "Play\\Pause", self:command_toggle(), self.ICONS.PLAY_PAUSE }) - if self.status ~= self.STOPPED and self.status ~= self.DISCONNECTED then + if self:playing_or_paused() then if self.list_array and self.list_array[self.current_number-1] then table.insert(new_menu, { "Prev: " .. @@ -750,7 +756,7 @@ function awesompd:remove_hint() end function awesompd:notify_track() - if self.status ~= awesompd.STOPPED then + if self:playing_or_paused() then local caption = self.status_text local nf_text = self.get_display_name(self.current_track) local al_cover = nil @@ -823,14 +829,13 @@ function awesompd:update_widget() self:check_notify() end --- This function is called by update_track each time when the content --- of the widget text must be changed. +-- This function is called by update_track each time content of +-- the widget must be changed. function awesompd:update_widget_text() - if self.status == awesompd.DISCONNECTED or - self.status == awesompd.STOPPED then - self.text = self.status - else + if self:playing_or_paused() then self.text = self.get_display_name(self.current_track) + else + self.text = self.status end end |