]> git.rmz.io Git - dotfiles.git/commitdiff
awesome/mpd_widget: use ping command to sync state
authorSamir Benmendil <me@rmz.io>
Mon, 3 Aug 2020 21:06:54 +0000 (22:06 +0100)
committerSamir Benmendil <me@rmz.io>
Sat, 8 Aug 2020 10:48:23 +0000 (11:48 +0100)
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.

awesome/widgets/mpd_widget.lua

index 1dc42093e36e2b8db97b98fc7a8e0672da06ab8d..e68fd8cb470d6b187242843e965fec6be4de225a 100644 (file)
@@ -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)