From 9586f540ae01e25d832a019c0018cc5a138b4b31 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Wed, 4 Jun 2025 21:27:17 +1000 Subject: icons: better app icon guessing --- utils/Icons.qml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'utils') diff --git a/utils/Icons.qml b/utils/Icons.qml index 391e39c..ca3917c 100644 --- a/utils/Icons.qml +++ b/utils/Icons.qml @@ -102,9 +102,7 @@ Singleton { "395": "snowing" }) - readonly property var desktopEntrySubs: ({ - Firefox: "firefox" - }) + readonly property var desktopEntrySubs: ({}) readonly property var categoryIcons: ({ WebBrowser: "web", @@ -149,9 +147,21 @@ Singleton { property string osIcon: "" property string osName + function getDesktopEntry(name: string): DesktopEntry { + name = name.toLowerCase().replace(/ /g, "-"); + + if (desktopEntrySubs.hasOwnProperty(name)) + name = desktopEntrySubs[name]; + + return DesktopEntries.applications.values.find(a => a.id.toLowerCase() === name) ?? null; + } + + function getAppIcon(name: string): string { + return Quickshell.iconPath(getDesktopEntry(name)?.icon, "image-missing"); + } + function getAppCategoryIcon(name: string, fallback: string): string { - const lName = name.toLowerCase(); - const categories = DesktopEntries.applications.values.find(app => app.id.toLowerCase() === lName)?.categories; + const categories = getDesktopEntry(name)?.categories; if (categories) for (const [key, value] of Object.entries(categoryIcons)) -- cgit v1.2.3-freya