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
|
id: icon
|
||||||
|
|
||||||
implicitSize: details.implicitHeight
|
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 {
|
Column {
|
||||||
|
|
|
||||||
|
|
@ -102,9 +102,7 @@ Singleton {
|
||||||
"395": "snowing"
|
"395": "snowing"
|
||||||
})
|
})
|
||||||
|
|
||||||
readonly property var desktopEntrySubs: ({
|
readonly property var desktopEntrySubs: ({})
|
||||||
Firefox: "firefox"
|
|
||||||
})
|
|
||||||
|
|
||||||
readonly property var categoryIcons: ({
|
readonly property var categoryIcons: ({
|
||||||
WebBrowser: "web",
|
WebBrowser: "web",
|
||||||
|
|
@ -149,9 +147,21 @@ Singleton {
|
||||||
property string osIcon: ""
|
property string osIcon: ""
|
||||||
property string osName
|
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 {
|
function getAppCategoryIcon(name: string, fallback: string): string {
|
||||||
const lName = name.toLowerCase();
|
const categories = getDesktopEntry(name)?.categories;
|
||||||
const categories = DesktopEntries.applications.values.find(app => app.id.toLowerCase() === lName)?.categories;
|
|
||||||
|
|
||||||
if (categories)
|
if (categories)
|
||||||
for (const [key, value] of Object.entries(categoryIcons))
|
for (const [key, value] of Object.entries(categoryIcons))
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue