diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-06-04 21:27:17 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-06-04 21:27:17 +1000 |
| commit | 9586f540ae01e25d832a019c0018cc5a138b4b31 (patch) | |
| tree | 0b1fd2c08834664a023129b492374485cb0e5bd8 /utils/Icons.qml | |
| parent | feat: clear notifs shortcut (diff) | |
| download | caelestia-shell-9586f540ae01e25d832a019c0018cc5a138b4b31.tar.gz caelestia-shell-9586f540ae01e25d832a019c0018cc5a138b4b31.tar.bz2 caelestia-shell-9586f540ae01e25d832a019c0018cc5a138b4b31.zip | |
icons: better app icon guessing
Diffstat (limited to 'utils/Icons.qml')
| -rw-r--r-- | utils/Icons.qml | 20 |
1 files changed, 15 insertions, 5 deletions
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)) |