X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/82df41d64401dca57bc5cd0c71f374118ee47d1a..b47ffe60e244c9165f40371736079320ea2d848b:/awesome/widgets/mpc.lua?ds=inline diff --git a/awesome/widgets/mpc.lua b/awesome/widgets/mpc.lua index bd64fa8..ef56c43 100644 --- a/awesome/widgets/mpc.lua +++ b/awesome/widgets/mpc.lua @@ -32,7 +32,7 @@ function mpc.new(host, port, password, error_handler, ...) _try_reconnect = false, _idle_subsystems = { ... } }, { __index = mpc }) - self:_connect() + self:connect() return self end @@ -46,13 +46,9 @@ end function mpc:_error(err) self._connected = false self._error_handler(err) - self._try_reconnect = not self._try_reconnect - if self._try_reconnect then - self:_connect() - end end -function mpc:_connect() +function mpc:connect() if self._connected then return end -- Reset all of our state self._reply_handlers = {} @@ -197,7 +193,7 @@ function mpc:_send(command, callback) end function mpc:send(...) - self:_connect() + self:connect() if not self._connected then return end @@ -220,6 +216,14 @@ function mpc:toggle_play() end) end +function mpc:play() + self:send("play") +end + +function mpc:pause() + self:send("pause") +end + function clamp(x, min, max) return math.min(math.max(x, min), max) end