From: Samir Benmendil Date: Mon, 3 Aug 2020 21:06:54 +0000 (+0100) Subject: awesome/mpd_widget: use ping command to sync state X-Git-Url: https://git.rmz.io/dotfiles.git/commitdiff_plain/3754466c5a0f36d056dde3c27bc5bf666739da3e awesome/mpd_widget: use ping command to sync state The ping command does nothing other than return OK, but it will be sent in order of the `send()` call, i.e. after any previous invocation of `send()` and since the server will return strings in order, this guarantees that the previous `status` and `currentsong` command have been evaluated and contain data. --- diff --git a/awesome/widgets/mpd_widget.lua b/awesome/widgets/mpd_widget.lua index 1dc4209..e68fd8c 100644 --- a/awesome/widgets/mpd_widget.lua +++ b/awesome/widgets/mpd_widget.lua @@ -59,9 +59,7 @@ local function get_info(callback) local song = nil connection:send("currentsong", function(_, s) song = s end) - timer.start_new(0.10, function() - if status == nil or song == nil then return true end - + connection:send("ping", function() dbg.dump(status) dbg.dump(song)