From 16bf9ddfb31ebf1787fb1bd986441f105636ca1c Mon Sep 17 00:00:00 2001 From: jbperrin Date: Fri, 17 Jul 2026 12:23:09 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20restart=20photobooth-app=20apr=C3=A8s=20?= =?UTF-8?q?changement=20du=20bouton=20Supprimer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/api/system_api.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/backend/api/system_api.py b/backend/api/system_api.py index 5e2f36c..1cfd966 100644 --- a/backend/api/system_api.py +++ b/backend/api/system_api.py @@ -65,19 +65,34 @@ async def get_delete_button(request: Request): async def set_delete_button(request: Request, visible: bool): """Active ou désactive le bouton Supprimer dans l'UI de review photobooth-app. - Écrit userdata/private.css en temps réel — effectif à la prochaine capture, - sans redémarrage. + Écrit userdata/private.css puis redémarre photobooth-app pour que le CSS + soit pris en compte. """ + import asyncio, subprocess pb = request.app.state.photobooth_service config_svc = request.app.state.config_service ok = await pb.set_delete_button_visible(visible) if ok: config_svc.save_show_delete_button(visible) + # Redémarre photobooth-app en arrière-plan pour recharger le CSS + asyncio.create_task(_restart_photobooth()) return {"ok": ok, "visible": visible} +async def _restart_photobooth(): + import asyncio + await asyncio.sleep(0.5) + proc = await asyncio.create_subprocess_exec( + "sudo", "systemctl", "restart", "photobooth-app.service", + stdout=asyncio.subprocess.DEVNULL, + stderr=asyncio.subprocess.DEVNULL, + ) + await proc.wait() + logger.info("photobooth-app redémarré après changement CSS") + + @router.post("/system/screen/refresh") async def screen_refresh(request: Request): """Envoie F5 à l'écran HDMI connecté (Chromium kiosque Wayland/X11)."""