#!/usr/bin/env python3 """ Start DaemonControl GUI Launches the full GUI application with: - Main window with tabs (Dashboard, Jobs, History) - System tray integration - Job management """ import sys from pathlib import Path # Add project root to path project_root = Path(__file__).parent sys.path.insert(0, str(project_root)) from PyQt6.QtWidgets import QApplication, QSystemTrayIcon from gui import SystemTrayApp from core import setup_logger def check_system_tray_available() -> bool: """Check if system tray is available. Returns: True if system tray is supported, False otherwise """ if not QSystemTrayIcon.isSystemTrayAvailable(): print("=" * 70) print("WARNING: System Tray Not Available") print("=" * 70) print() print("Your desktop environment does not support system tray icons.") print("The GUI will start, but the system tray icon will not be visible.") print() print("To enable system tray:") print(" 1. Install AppIndicator extension (GNOME)") print(" 2. Use KDE Plasma, XFCE, or Cinnamon desktop") print() return False return True def main(): """Main entry point""" logger = setup_logger('gui') logger.info("Starting DaemonControl GUI...") try: # Create QApplication app = QApplication(sys.argv) # Don't quit when windows are closed (tray keeps running) app.setQuitOnLastWindowClosed(False) # Check system tray (just warn, don't fail) tray_available = check_system_tray_available() print("=" * 70) print(" DaemonControl - Full GUI Mode") print("=" * 70) print() print("Starting DaemonControl GUI...") print() print("Features:") print(" 📊 Dashboard - Overview and statistics") print(" ⚙️ Jobs - Manage scheduled jobs") print(" 📜 History - View execution logs") if tray_available: print(" 🔔 System Tray - Background control") print() print("Use File → Exit or system tray → Exit to quit") print() # Create system tray app (includes main window) tray_app = SystemTrayApp() if tray_available: tray_app.show() # Show main window on startup (different from tray-only mode) tray_app.show_main_window() logger.info("GUI started successfully") # Run application event loop sys.exit(app.exec()) except KeyboardInterrupt: logger.info("GUI interrupted by user") print("\nShutdown requested by user") sys.exit(0) except Exception as e: logger.error(f"GUI startup failed: {e}", exc_info=True) print(f"\nERROR: {e}") import traceback traceback.print_exc() sys.exit(1) if __name__ == '__main__': main()