From 6314ce4ad10a2a6855d70398787bc615786b64c0 Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Thu, 23 Apr 2026 09:50:21 +0200 Subject: [PATCH] resolve window icon relative to executable path The relative path failed because flutter run's cwd differs from the bundle directory. Now reads /proc/self/exe to find the binary location and builds the icon path from there. Co-Authored-By: Claude Opus 4.6 (1M context) --- linux/runner/my_application.cc | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/linux/runner/my_application.cc b/linux/runner/my_application.cc index f2cb8be8..e9fbc230 100644 --- a/linux/runner/my_application.cc +++ b/linux/runner/my_application.cc @@ -116,12 +116,21 @@ static void my_application_activate(GApplication* application) { gtk_window_set_default_size(window, 1280, 720); - g_autoptr(GError) icon_error = nullptr; - GdkPixbuf* icon = gdk_pixbuf_new_from_file( - "data/flutter_assets/assets/logo/clide-logo-256.png", &icon_error); - if (icon != nullptr) { - gtk_window_set_icon(window, icon); - g_object_unref(icon); + // Resolve icon relative to the executable, not cwd. + { + g_autofree gchar* exe_path = g_file_read_link("/proc/self/exe", nullptr); + if (exe_path != nullptr) { + g_autofree gchar* exe_dir = g_path_get_dirname(exe_path); + g_autofree gchar* icon_path = g_build_filename( + exe_dir, "data", "flutter_assets", "assets", "logo", + "clide-logo-256.png", nullptr); + g_autoptr(GError) icon_error = nullptr; + GdkPixbuf* icon = gdk_pixbuf_new_from_file(icon_path, &icon_error); + if (icon != nullptr) { + gtk_window_set_icon(window, icon); + g_object_unref(icon); + } + } } g_autoptr(FlDartProject) project = fl_dart_project_new();