feat: add system tray icon with Show UI and Exit actions
Lint & Test / test (push) Successful in 9s

Adds pystray-based tray icon (green play button) that runs alongside
uvicorn. Double-click opens the web UI in the browser, Exit triggers
graceful shutdown. Disabled with --no-tray flag for headless/service mode.
This commit is contained in:
2026-03-23 14:05:13 +03:00
parent 4d1bb78c83
commit 6500d6f615
3 changed files with 124 additions and 6 deletions
+22 -6
View File
@@ -216,6 +216,11 @@ def main():
action="store_true",
help="Show the current API token and exit",
)
parser.add_argument(
"--no-tray",
action="store_true",
help="Disable system tray icon (for headless/service mode)",
)
args = parser.parse_args()
@@ -235,12 +240,23 @@ def main():
print("\nAuthentication is DISABLED (no tokens configured)")
return
uvicorn.run(
"media_server.main:app",
host=args.host,
port=args.port,
reload=False,
)
# Start system tray icon (unless disabled)
tray_icon = None
if not args.no_tray:
from .tray import start_tray
tray_icon = start_tray(args.host, args.port)
try:
uvicorn.run(
"media_server.main:app",
host=args.host,
port=args.port,
reload=False,
)
finally:
if tray_icon is not None:
tray_icon.stop()
if __name__ == "__main__":