From a8262ab7a679f7f318ba500509619f5323db9ea3 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 7 Apr 2026 12:22:58 +0300 Subject: [PATCH] flipoff: allow hiding the GUI with `--headless` Signed-off-by: NotAShelf Change-Id: I741f75f8c2615dacea5f6ca703d6da716a6a6964 --- flipoff.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/flipoff.py b/flipoff.py index c6315d2..ca297aa 100644 --- a/flipoff.py +++ b/flipoff.py @@ -1,3 +1,4 @@ +import argparse import asyncio import os import time @@ -64,6 +65,14 @@ async def async_poweroff() -> None: def main() -> None: + parser = argparse.ArgumentParser(description="Hand gesture poweroff utility") + parser.add_argument( + "--headless", + action="store_true", + help="Hide GUI window and run in headless mode", + ) + args = parser.parse_args() + if not MODEL_PATH: raise RuntimeError("FLIPOFF_MODEL_PATH environment variable not set") @@ -112,12 +121,14 @@ def main() -> None: last_trigger = now loop.run_until_complete(async_poweroff()) - cv2.imshow("Gesture Poweroff", frame) - if cv2.waitKey(1) & 0xFF == 27: - break + if not args.headless: + cv2.imshow("Gesture Poweroff", frame) + if cv2.waitKey(1) & 0xFF == 27: + break cap.release() - cv2.destroyAllWindows() + if not args.headless: + cv2.destroyAllWindows() detector.close() loop.close()