icons: better app icon guessing
This commit is contained in:
parent
391a02462c
commit
9586f540ae
2 changed files with 16 additions and 6 deletions
|
|
@ -28,7 +28,7 @@ Item {
|
|||
id: icon
|
||||
|
||||
implicitSize: details.implicitHeight
|
||||
source: Quickshell.iconPath(DesktopEntries.applications.values.find(a => a.id === Hyprland.activeClient?.wmClass.toLowerCase())?.icon, "image-missing")
|
||||
source: Icons.getAppIcon(Hyprland.activeClient?.wmClass ?? "")
|
||||
}
|
||||
|
||||
Column {
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue