fix: use app icon precedence for individual app categories
Not only is precedence used to choose which window is used to represent the workspace, it is also now used to choose which category of each window is used to represent the app itself.
This commit is contained in:
parent
f611ec3c25
commit
31254372c8
1 changed files with 34 additions and 28 deletions
|
|
@ -127,6 +127,31 @@ Singleton {
|
|||
Office: "content_paste"
|
||||
})
|
||||
|
||||
// App icon precedence
|
||||
// Used to preferentially pick app icon for display
|
||||
readonly property var appIconPrec: ({
|
||||
sports_esports: 10,
|
||||
code: 9,
|
||||
music_note: 9,
|
||||
content_paste: 9,
|
||||
graphic_eq: 8,
|
||||
tv: 8,
|
||||
edit_note: 6,
|
||||
language: 5,
|
||||
business_messages: 5,
|
||||
files: 4,
|
||||
mic: 4,
|
||||
construction: 4,
|
||||
terminal: 3,
|
||||
monitor_heart: 3,
|
||||
security: 3,
|
||||
photo_library: 3,
|
||||
archive: 2,
|
||||
settings: 2,
|
||||
build: 1,
|
||||
host: 0
|
||||
})
|
||||
|
||||
function getDesktopEntry(name: string): DesktopEntry {
|
||||
name = name.toLowerCase().replace(/ /g, "-");
|
||||
|
||||
|
|
@ -146,37 +171,18 @@ Singleton {
|
|||
function getAppCategoryIcon(name: string, fallback: string): string {
|
||||
const categories = getDesktopEntry(name)?.categories;
|
||||
|
||||
let values = [];
|
||||
if (categories)
|
||||
for (const [key, value] of Object.entries(categoryIcons))
|
||||
if (categories.includes(key))
|
||||
return value;
|
||||
return fallback;
|
||||
}
|
||||
if (categories.includes(key) && value in appIconPrec)
|
||||
values.push(value);
|
||||
|
||||
// App icon precedence
|
||||
// Used to preferentially display apps in a workspace
|
||||
readonly property var appIconPrec: ({
|
||||
sports_esports: 10,
|
||||
code: 9,
|
||||
music_note: 9,
|
||||
content_paste: 9,
|
||||
graphic_eq: 8,
|
||||
tv: 8,
|
||||
edit_note: 6,
|
||||
language: 5,
|
||||
business_messages: 5,
|
||||
files: 4,
|
||||
host: 4,
|
||||
mic: 4,
|
||||
construction: 4,
|
||||
monitor_heart: 3,
|
||||
security: 3,
|
||||
archive: 3,
|
||||
settings: 2,
|
||||
build: 2,
|
||||
photo_library: 1,
|
||||
terminal: 1
|
||||
})
|
||||
if (values.length !== 0) {
|
||||
return values.reduce((a, b) => appIconPrec[a] > appIconPrec[b] ? a : b);
|
||||
} else {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
function getWorkspaceIcon(workspace: HyprlandWorkspace): string {
|
||||
if (!workspace || workspace.toplevels.values.length === 0) return "add";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue