X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/66dde90206fe181cbe49d236925a8d4e6a86ec54..8bda449c576a9ca1d4f88a82d999f95e9de6e203:/widgets/mpd.lua?ds=inline diff --git a/widgets/mpd.lua b/widgets/mpd.lua index e3ed50d..36c3ed7 100644 --- a/widgets/mpd.lua +++ b/widgets/mpd.lua @@ -16,7 +16,7 @@ local wibox = require("wibox") local io = { popen = io.popen } local os = { execute = os.execute, getenv = os.getenv } -local string = { format = string.format, +local string = { format = string.format, gmatch = string.gmatch } local setmetatable = setmetatable @@ -28,7 +28,7 @@ local mpd = {} local function worker(args) local args = args or {} local timeout = args.timeout or 2 - local password = args.password or "\"\"" + 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" @@ -38,7 +38,19 @@ local function worker(args) local mpdcover = helpers.scripts_dir .. "mpdcover" local mpdh = "telnet://" .. host .. ":" .. port - local echo = "echo 'password " .. password .. "\nstatus\ncurrentsong\nclose'" + + local echo = nil + + if password == "" then + echo = "(echo -e 'status'; sleep 0.1;" .. + "echo -e 'currentsong'; sleep 0.1;" .. + "echo -e 'close')" + else + echo = "(echo -e 'password " .. password .. "'" .. + "echo -e 'status'; sleep 0.1;" .. + "echo -e 'currentsong'; sleep 0.1;" .. + "echo -e 'close')" + end mpd.widget = wibox.widget.textbox('')