import argparse import asyncio import sys from config import AppConfig from server import run_server from state import MessageState def main() -> None: parser = argparse.ArgumentParser(description="Sahsa Clock Display") parser.add_argument( "--dev", action="store_true", help="Windowed dev mode — renders to an x11 window instead of the framebuffer", ) parser.add_argument( "--no-display", action="store_true", help="Start the HTTP server only, with no display output (useful for testing the dashboard/API)", ) parser.add_argument( "--config", default="config.toml", metavar="PATH", help="Path to config.toml (default: config.toml)", ) args = parser.parse_args() config = AppConfig.load(args.config) state = MessageState() if not args.no_display: # Import display only when needed — keeps --no-display working without pygame from display import DisplayThread display = DisplayThread(state, config, dev_mode=args.dev) display.start() try: asyncio.run(run_server(state, config)) except KeyboardInterrupt: print("\n[sahsa-clock] Shutting down.") sys.exit(0) if __name__ == "__main__": main()