From 6f9f313ba4503d0cd09aa06f3b88c69efaae7c13 Mon Sep 17 00:00:00 2001 From: Alexander Yakushev Date: Fri, 19 Aug 2011 12:20:15 +0300 Subject: Bugfixes and tidy up --- README | 4 +++- awesompd.lua | 19 ++++++++++--------- jamendo.lua | 4 ++-- rcsample.lua | 14 +++++++++----- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/README b/README index 2a2e3bc..b1c3ecc 100644 --- a/README +++ b/README @@ -1,3 +1,5 @@ -This is a MPD widget for AwesomeWM. +This is an advanced MPD widget\client for AwesomeWM. For the detailed installation guide see http://awesome.naquadah.org/wiki/Awesompd_widget . + +Also you can find an example of widget configuration in file rcsample.lua. diff --git a/awesompd.lua b/awesompd.lua index 0d28991..88c147b 100644 --- a/awesompd.lua +++ b/awesompd.lua @@ -1,7 +1,7 @@ --------------------------------------------------------------------------- --- @author Alexander Yakushev <yakushev.alex@gmail.com> +-- @author Alexander Yakushev -- @copyright 2010-2011 Alexander Yakushev --- @release v1.0.2 +-- @release v1.0.4 --------------------------------------------------------------------------- require('utf8') @@ -52,7 +52,7 @@ function awesompd.try_load(file) end end --- Just like awful.util.pread, but takes an argument to read like +-- Just like awful.util.pread, but takes an argument how to read like -- "*line" or "*all". function awesompd.pread(com, mode) local f = io.popen(com, 'r') @@ -651,6 +651,10 @@ end function awesompd.split(s) local l = { n = 0 } + if s == "" then + return l + end + s = s .. "\n" local f = function (s) l.n = l.n + 1 l[l.n] = s @@ -879,6 +883,7 @@ end -- folders. If there is no cover art either returns the default album -- cover. function awesompd:get_cover(track) + dbg(self.ICONS.DEFAULT_ALBUM_COVER) return jamendo.try_get_cover(track) or self:try_get_local_cover() or self.ICONS.DEFAULT_ALBUM_COVER end @@ -887,27 +892,23 @@ end -- playing. function awesompd:try_get_local_cover() if self.mpd_config then + local result -- First find the music directory in MPD configuration file local _, _, music_folder = string.find( self.pread('cat ' .. self.mpd_config .. ' | grep -v "#" | grep music_directory', "*line"), 'music_directory%s+"(.+)"') music_folder = music_folder .. "/" - dbg("musfolder", music_folder) -- Get the path to the file currently playing. local _, _, current_file_folder = string.find(self:command_read('current -f "%file%"', "*line"), '(.+%/).*') local folder = music_folder .. current_file_folder - dbg("folder", folder) -- Get all images in the folder local covers = self.pread('ls "' .. folder .. '" | grep -P "\.jpg\|\.png\|\.gif"', "*all") local covers_table = self.split(covers) - dbg('wtf', 'ls "' .. folder .. '" | grep "\.jpg\|\.png\|\.gif"') - dbg('first', covers) - if covers_table.n > 0 then result = folder .. covers_table[1] if covers_table.n > 1 then @@ -921,6 +922,6 @@ function awesompd:try_get_local_cover() end end end + return result end - return result end diff --git a/jamendo.lua b/jamendo.lua index 1dd421c..78dc962 100644 --- a/jamendo.lua +++ b/jamendo.lua @@ -1,7 +1,7 @@ --------------------------------------------------------------------------- --- @author Alexander Yakushev <yakushev.alex@gmail.com> +-- @author Alexander Yakushev -- @copyright 2011 Alexander Yakushev --- @release v1.0.2 +-- @release v1.0.4 --------------------------------------------------------------------------- module('jamendo', package.seeall) diff --git a/rcsample.lua b/rcsample.lua index 2cf5938..94c46af 100644 --- a/rcsample.lua +++ b/rcsample.lua @@ -97,14 +97,18 @@ mysystray = widget({ type = "systray" }) -- possible formats: awesompd.FORMAT_MP3, awesompd.FORMAT_OGG musicwidget.jamendo_format = awesompd.FORMAT_MP3 - -- If true, song notifications for Jamendo tracks will also contain - -- album cover image. - musicwidget.show_jamendo_album_covers = true + -- If true, song notifications for Jamendo tracks and local tracks + -- will also contain album cover image. + musicwidget.show_album_cover = true -- Specify how big in pixels should an album cover be. Maximum value -- is 100. musicwidget.album_cover_size = 50 - + + -- This option is necessary if you want the album covers to be shown + -- for your local tracks. + musicwidget.mpd_config = "/home/username/.mpdconf" + -- Specify decorators on the left and the right side of the -- widget. Or just leave empty strings if you decorate the widget -- from outside. @@ -129,7 +133,7 @@ mysystray = widget({ type = "systray" }) musicwidget:run() -- After all configuration is done, run the widget -- END OF AWESOMPD WIDGET DECLARATION --- Don't forget to add the widget to the wibox. It is done on the line 202. +-- Don't forget to add the widget to the wibox. It is done on the line 207. mywibox = {} mypromptbox = {} -- cgit v1.2.3