function widget:error_handler(err)
self._textbox:set_text("Error: " .. tostring(err))
- timer.start_new(10, function()
- self._connection:send("ping")
- end)
+ self._status = {}
end
function widget:run()
"player", function(conn)
conn:send("status", function(err, status)
local songchanged = self._status.songid ~= status.songid
+ local statechanged = self._status.state ~= status.state
self._status = status
if not songchanged then
self:update_widget()
+ if statechanged then
+ self:popup_oneshot(5)
+ end
return
end
end
)
+ self._keep_alive_timer = timer {
+ timeout = 1
+ , autostart = true
+ , callback = function() self._connection:connect() end
+ , call_now = true
+ }
+
self._timer = timer({ timeout = 1 })
self._timer:connect_signal("timeout", function() self:popup_update() end)