X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/f31c5cc856640aa4cd5a7299974ba02abacd95a7..cc739f08e74418d870df1389338cc5ccead57538:/widgets/mpd.lua?ds=sidebyside diff --git a/widgets/mpd.lua b/widgets/mpd.lua index 41233cd..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 @@ -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('')