Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bad call to find when music dir can't be found in mpd_config #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions awesompd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1199,16 +1199,17 @@ function awesompd:try_get_local_cover(current_file)
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 .. "/"
local mf = self.pread('cat ' .. self.mpd_config .. ' | grep -v ^"#" | grep music_directory', "*line")
if mf then
local _, _, music_folder = string.find(mf, 'music_directory%s+"(.+)"')
music_folder = music_folder .. "/"

-- If the music_folder is specified with ~ at the beginning,
-- replace it with user home directory
if string.sub(music_folder, 1, 1) == "~" then
local user_folder = self.pread("echo ~", "*line")
music_folder = user_folder .. string.sub(music_folder, 2)
-- If the music_folder is specified with ~ at the beginning,
-- replace it with user home directory
if string.sub(music_folder, 1, 1) == "~" then
local user_folder = self.pread("echo ~", "*line")
music_folder = user_folder .. string.sub(music_folder, 2)
end
end

-- Get the path to the file currently playing.
Expand Down