diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-10 13:06:18 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-10 13:06:18 +0100 |
| commit | ea5a277c6b8bb2ba48b0ca8822797cf6ab0b3405 (patch) | |
| tree | d2ce1c0fe156dcd9c53196c151bdfed091a25618 /tests/test_server.py | |
| parent | 8ec2352c22780202fcd39982f1c3e65d2dae0cc1 (diff) | |
| download | deck-it-ea5a277c6b8bb2ba48b0ca8822797cf6ab0b3405.tar.gz deck-it-ea5a277c6b8bb2ba48b0ca8822797cf6ab0b3405.zip | |
feat: the PC tells the tablet it is going to sleep
deckit/sleep.py holds an elogind delay inhibitor and watches
PrepareForSleep with dbus-monitor. On a suspend the server marks its
answers with X-Deckit-Sleep for 2 s, so the tablet's next poll shows "The
PC is asleep" at once and drops its wake lock, then lets the inhibitor go.
On resume it takes the inhibitor again. The 15 s silence fallback stays,
worded "The PC is not answering", for a crash or a dropped tunnel.
The inhibitor's command is `tail --pid=<server>` and dbus-monitor has a
parent-death signal, so a killed server leaves no lock delaying every
suspend (checked with kill -9: both gone within 2 s).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/test_server.py')
| -rw-r--r-- | tests/test_server.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/test_server.py b/tests/test_server.py index 668b5d2..d37723e 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -90,6 +90,18 @@ class Server(unittest.TestCase): {"Host": "127.0.0.1:8765", **ORIGIN, "Content-Type": "audio/wav"}, b"RIFF")[0], 401) + def test_answers_say_the_pc_is_going_to_sleep(self): + conn = UnixConnection(self.sock) + srv.sleep.sleeping.set() + try: + conn.request("GET", "/api/demo", headers=HOST) + r = conn.getresponse() + r.read() + finally: + srv.sleep.sleeping.clear() + conn.close() + self.assertEqual(r.getheader("X-Deckit-Sleep"), "1") + def test_nerd_font(self): from unittest import mock import tempfile |
