From ea734ba1c8a06dae3aba2848f94db4cb9fca5f45 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Mon, 7 Aug 2023 13:29:40 -0700 Subject: [PATCH] Open app in native view on starting it in GUI mode instead of on web browser - Opens settings page on first run and landing page after in GUI mode Previously was only opening the GUI on linux after first run as it doesn't have a system tray - Both the views are from the web interface but are rendered within the app instead of the browser --- docs/setup.md | 2 +- src/khoj/main.py | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/docs/setup.md b/docs/setup.md index 25890126..a2bcc2bc 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -24,7 +24,7 @@ For more detailed Windows installation and troubleshooting, see [Windows Install ### 2. Start -Run the following command from your terminal to start the Khoj backend and open Khoj in your browser. +Run the following command in your terminal to start the Khoj backend and open the Khoj native GUI ```shell khoj --gui diff --git a/src/khoj/main.py b/src/khoj/main.py index 89623649..a1780e1b 100644 --- a/src/khoj/main.py +++ b/src/khoj/main.py @@ -12,7 +12,6 @@ import logging import threading import warnings from platform import system -import webbrowser # Ignore non-actionable warnings warnings.filterwarnings("ignore", message=r"snapshot_download.py has been made private", category=FutureWarning) @@ -100,15 +99,10 @@ def run(): server = ServerThread(start_server_func=lambda: start_server(app, host=args.host, port=args.port)) logger.info(f"🌗 Khoj is running at {url}") - try: - startup_url = url if args.config else f"{url}/config" - webbrowser.open(startup_url) - except: - logger.warning(f"🚧 Unable to open browser. Please open {url} manually to configure or use Khoj.") - # Show Main Window on First Run Experience or if on Linux - if args.config is None or system() not in ["Windows", "Darwin"]: - main_window.show() + # Show config window on first run and main window otherwise + startup_window = main_window.show_page() if args.config else main_window.show_page("config") + startup_window() # Setup Signal Handlers signal.signal(signal.SIGINT, sigint_handler)