From 76a225a2350b7215986be23ff77812c2f9588421 Mon Sep 17 00:00:00 2001 From: VallierDev <49166112@qq.com> Date: Thu, 22 Oct 2026 08:54:23 -0700 Subject: [PATCH] Tray: install the symbolic icon into the user hicolor theme (#90) v0.2.25 showed KDE's unknown icon on Plasma 6.8 (#87). Plasma resolves SNI icons theme by theme, trying dash-trimmed names in each theme before the IconThemePath app theme, which comes last, so a cache-only icon is easy to lose. Write it to $XDG_DATA_HOME/icons/hicolor (found by every panel's default lookup; only when changed) and keep that as the theme path. The new name "uuremote-tray-symbolic" cannot trim into the colored "uu-remote-linux" app icon and avoids entries cached under the old name. Checked with KIconLoader on Plasma 6.7 (Plasma's IconThemePath setup and the global loader both resolve it, with the colored icon installed too). Co-authored-by: VallierDev <24893073+VallierDev@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 --- c_engine/assist_window.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/c_engine/assist_window.c b/c_engine/assist_window.c index 2d2e5a8..7d3e1fb 100644 --- a/c_engine/assist_window.c +++ b/c_engine/assist_window.c @@ -306,9 +306,11 @@ static void on_status_menu(GtkStatusIcon *i, guint button, guint time, gpointer gtk_menu_popup_at_pointer(GTK_MENU(tray_menu), NULL); } // Monochrome tray icon that follows light/dark panels: GTK and the GNOME AppIndicator extension -// recolor "-symbolic" names, KDE recolors the ColorScheme-Text class. Written to the user cache -// and offered as an icon theme path, so it needs no package install. -static const char TRAY_ICON_NAME[] = "uu-remote-linux-symbolic"; +// recolor "-symbolic" names, KDE recolors the ColorScheme-Text class. Installed into the user's +// hicolor theme (found by every panel's default lookup) and also offered as the icon theme path, +// so it needs no package install. KDE tries dash-trimmed names ("uu-remote-linux") in each theme +// before the next one, so the name must not trim into the colored app icon (#87). +static const char TRAY_ICON_NAME[] = "uuremote-tray-symbolic"; static const char TRAY_ICON_SVG[] = "" "" @@ -316,15 +318,16 @@ static const char TRAY_ICON_SVG[] = "A1.5 1.5 0 0 1 1 10.5v-7A1.5 1.5 0 0 1 2.5 2zm0 1.5v7h11v-7z\"/>" "\n"; -// Returns the theme path holding the icon (hicolor layout plus a loose copy), or NULL. +// Returns the icon theme root holding the icon ($XDG_DATA_HOME/icons), or NULL. static gchar *write_tray_icon(void) { - gchar *root = g_build_filename(g_get_user_cache_dir(), "uu-remote-linux", "icons", NULL); + gchar *root = g_build_filename(g_get_user_data_dir(), "icons", NULL); gchar *apps = g_build_filename(root, "hicolor", "scalable", "apps", NULL); gchar *file = g_strconcat(TRAY_ICON_NAME, ".svg", NULL); - gchar *themed = g_build_filename(apps, file, NULL), *loose = g_build_filename(root, file, NULL); - int ok = g_mkdir_with_parents(apps, 0700) == 0 && g_file_set_contents(themed, TRAY_ICON_SVG, -1, NULL) - && g_file_set_contents(loose, TRAY_ICON_SVG, -1, NULL); - g_free(apps); g_free(file); g_free(themed); g_free(loose); + gchar *path = g_build_filename(apps, file, NULL), *current = NULL; + // Rewriting an unchanged file would only make icon caches rescan. + int ok = g_file_get_contents(path, ¤t, NULL, NULL) && strcmp(current, TRAY_ICON_SVG) == 0; + if (!ok) ok = g_mkdir_with_parents(apps, 0755) == 0 && g_file_set_contents(path, TRAY_ICON_SVG, -1, NULL); + g_free(apps); g_free(file); g_free(path); g_free(current); if (!ok) { g_free(root); return NULL; } return root; }