listener: mark device as inactive after resume so that settings are correctly pushed

This commit is contained in:
Peter F. Patel-Schneider 2020-02-22 07:42:10 -05:00
parent 789f5f05c3
commit 23c0397764
2 changed files with 7 additions and 3 deletions

View File

@ -106,7 +106,7 @@ def main():
if args.restart_on_wake_up:
_upower.watch(listener.start_all, listener.stop_all)
else:
_upower.watch(listener.ping_all)
_upower.watch(lambda: listener.ping_all(True))
# main UI event loop
ui.run_loop(listener.start_all, listener.stop_all, args.window!='only', args.window!='hide')

View File

@ -291,12 +291,16 @@ def stop_all():
for l in listeners:
l.join()
def ping_all():
# ping all devices to find out whether they are connected
# after a resume, the device may have been off
# so mark its saved status to ensure that the status is pushed to the device when it comes back
def ping_all(resuming = False):
for l in _all_listeners.values():
count = l.receiver.count()
if count:
for dev in l.receiver:
if resuming:
dev.status._active = False
dev.ping()
l._status_changed(dev)
count -= 1