From 442e3beb12e5c54824077b7f3ae6fb999cbe1d12 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 1 Jun 2026 20:48:13 +0100 Subject: [PATCH] Keep online Move receiver alive across HID churn --- tools/online_move_music_sync.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tools/online_move_music_sync.py b/tools/online_move_music_sync.py index beae3ba..8311159 100644 --- a/tools/online_move_music_sync.py +++ b/tools/online_move_music_sync.py @@ -14,6 +14,7 @@ import base64 import colorsys import json import math +import errno import os import subprocess import sys @@ -45,8 +46,14 @@ with open(log, "a", encoding="utf-8") as f: last = {} def write_rgb(path, r, g, b): - with open(path, "wb", buffering=0) as device: - device.write(bytes([0x06, 0, max(0, min(255, r)), max(0, min(255, g)), max(0, min(255, b)), 0, 0, 0, 0])) + try: + with open(path, "wb", buffering=0) as device: + device.write(bytes([0x06, 0, max(0, min(255, r)), max(0, min(255, g)), max(0, min(255, b)), 0, 0, 0, 0])) + return True + except OSError as ex: + if ex.errno in (errno.ENOENT, errno.ENODEV, errno.EACCES): + return False + raise for path in moves.values(): write_rgb(path, 0, 0, 0) @@ -65,8 +72,8 @@ for line in sys.stdin: continue if last.get(name) == rgb: continue - write_rgb(path, rgb[0], rgb[1], rgb[2]) - last[name] = rgb + if write_rgb(path, rgb[0], rgb[1], rgb[2]): + last[name] = rgb for path in moves.values(): write_rgb(path, 0, 0, 0)