- commit
- e825a7b1533a7e6daaa130fe90f34a9fc08def7d
- parent
- e6ac3d1e27a398c85b64b33f8b17f5aa2ccfaeda
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2024-11-19 08:23
pause on suspend
Diffstat
| M | cplay.py | 8 | ++++++++ |
1 files changed, 8 insertions, 0 deletions
diff --git a/cplay.py b/cplay.py
@@ -798,12 +798,20 @@ class Application: 798 798 sel.register(sys.stdin, selectors.EVENT_READ) 799 799 sel.register(self.resize_in, selectors.EVENT_READ) 800 800 sel.register(player.socket, selectors.EVENT_READ) -1 801 prev = time.time() 801 802 802 803 while True: 803 804 player.finish_seek() 804 805 805 806 timeout = 0.5 if player.is_playing else None 806 807 for key, _mask in sel.select(timeout): -1 808 # if we have skipped multiple seconds, it is probably -1 809 # because the system was suspended. This heuristic is much -1 810 # simpler than detecting suspend via dbus. -1 811 if player.is_playing and time.time() - prev > 5: -1 812 player.stop() -1 813 prev = time.time() -1 814 807 815 if key.fileobj is self.resize_in: 808 816 os.read(self.resize_in, 8) 809 817 self.on_resize()