Catch luampd socket error and reconnect

This commit is contained in:
crater2150 2012-03-26 16:30:53 +02:00
parent c56bbec1db
commit e37b2d3403
2 changed files with 3 additions and 4 deletions

View file

@ -16,9 +16,7 @@ mpdmap = {
n = mpd.ctrl.next,
N = mpd.ctrl.prev,
s = function() awful.util.spawn("mpd") end,
g = function () awful.util.spawn(cmd.mpd_client) end,
d = mpd.disconnect,
c = mpd.connect
g = function () awful.util.spawn(cmd.mpd_client) end
}
mpdpromts = {
name = "MPD PROMPTS",

View file

@ -36,7 +36,8 @@ M.disconnect = function()
end
M.ensure_connection = function()
if conn == nil then M.connect() end
-- luampd throws SOCKET_ERRORs all the time. catch them and reconnect
if conn == nil or not pcall(conn:status()) then M.connect() end
end
-- }}}