- local args = args or {}
- local timeout = args.timeout or 2
- local password = args.password or ""
- local host = args.host or "127.0.0.1"
- local port = args.port or "6600"
- local music_dir = args.music_dir or os.getenv("HOME") .. "/Music"
- local cover_size = args.cover_size or 100
- local default_art = args.default_art or ""
- local followmouse = args.followmouse or false
- local settings = args.settings or function() end
-
- local mpdcover = helpers.scripts_dir .. "mpdcover"
- local mpdh = "telnet://" .. host .. ":" .. port
- local echo = "/bin/echo -e 'password " .. password .. "\nstatus\ncurrentsong\nclose'"
-
- mpd.widget = wibox.widget.textbox('')
-
- mpd_notification_preset = {
- title = "Now playing",
- timeout = 6
- }
+ local args = args or {}
+ local timeout = args.timeout or 2
+ local password = (args.password and #args.password > 0 and string.format("password %s\\n", args.password)) or ""
+ local host = args.host or "127.0.0.1"
+ local port = args.port or "6600"
+ local music_dir = args.music_dir or os.getenv("HOME") .. "/Music"
+ local cover_pattern = args.cover_pattern or "*\\.(jpg|jpeg|png|gif)$"
+ local cover_size = args.cover_size or 100
+ local default_art = args.default_art
+ local notify = args.notify or "on"
+ local followtag = args.followtag or false
+ local settings = args.settings or function() end
+
+ local mpdh = string.format("telnet://%s:%s", host, port)
+ local echo = string.format("printf \"%sstatus\\ncurrentsong\\nclose\\n\"", password)
+ local cmd = string.format("%s | curl --connect-timeout 1 -fsm 3 %s", echo, mpdh)
+
+ mpd.widget = wibox.widget.textbox()
+
+ mpd_notification_preset = { title = "Now playing", timeout = 6 }