diff options
| -rw-r--r-- | README.md | 6 | ||||
| -rw-r--r-- | config/BarConfig.qml | 6 | ||||
| -rw-r--r-- | config/Config.qml | 3 | ||||
| -rw-r--r-- | utils/Icons.qml | 30 |
4 files changed, 40 insertions, 5 deletions
@@ -420,6 +420,12 @@ default, you must create it manually. "name": "steam", "icon": "sports_esports" } + ], + "windowIcons": [ + { + "regex": "steam(_app_(default|[0-9]+))?", + "icon": "sports_esports" + } ] }, "excludedScreens": [""], diff --git a/config/BarConfig.qml b/config/BarConfig.qml index 6254d94..2e04108 100644 --- a/config/BarConfig.qml +++ b/config/BarConfig.qml @@ -79,6 +79,12 @@ JsonObject { property string activeLabel: "" property string capitalisation: "preserve" // upper, lower, or preserve - relevant only if label is empty property list<var> specialWorkspaceIcons: [] + property list<var> windowIcons: [ + { + regex: "steam(_app_(default|[0-9]+))?", + icon: "sports_esports" + } + ] } component ActiveWindow: JsonObject { diff --git a/config/Config.qml b/config/Config.qml index 2a261e7..584aeba 100644 --- a/config/Config.qml +++ b/config/Config.qml @@ -176,7 +176,8 @@ Singleton { occupiedLabel: bar.workspaces.occupiedLabel, activeLabel: bar.workspaces.activeLabel, capitalisation: bar.workspaces.capitalisation, - specialWorkspaceIcons: bar.workspaces.specialWorkspaceIcons + specialWorkspaceIcons: bar.workspaces.specialWorkspaceIcons, + windowIcons: bar.workspaces.windowIcons }, activeWindow: { compact: bar.activeWindow.compact, diff --git a/utils/Icons.qml b/utils/Icons.qml index c06cbf8..34f8049 100644 --- a/utils/Icons.qml +++ b/utils/Icons.qml @@ -79,6 +79,26 @@ Singleton { Office: "content_paste" }) + // Checks if a name matches an icon config. Icon configs can have the following keys: + // - name: The exact name of the icon + // - regex: A regex to match against the name (takes priority over name) + // - flags: The regex flags (only used if regex is set) + // - icon: The icon to use + function matchIconConfig(name: string, iconConfig: var): bool { + if (!iconConfig.icon) + return false; + + if (iconConfig.regex) { + const re = new RegExp(iconConfig.regex, iconConfig.flags ?? ""); + if (re.test(name)) + return true; + } else if (iconConfig.name === name) { + return true; + } + + return false; + } + function getAppIcon(name: string, fallback: string): string { const icon = DesktopEntries.heuristicLookup(name)?.icon; if (fallback !== "undefined") @@ -87,6 +107,10 @@ Singleton { } function getAppCategoryIcon(name: string, fallback: string): string { + for (const iconConfig of Config.bar.workspaces.windowIcons) + if (matchIconConfig(name, iconConfig)) + return iconConfig.icon; + const categories = DesktopEntries.heuristicLookup(name)?.categories; if (categories) @@ -188,11 +212,9 @@ Singleton { function getSpecialWsIcon(name: string): string { name = name.toLowerCase().slice("special:".length); - for (const iconConfig of Config.bar.workspaces.specialWorkspaceIcons) { - if (iconConfig.name === name) { + for (const iconConfig of Config.bar.workspaces.specialWorkspaceIcons) + if (matchIconConfig(name, iconConfig)) return iconConfig.icon; - } - } if (name === "special") return "star"; |