diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-05-18 00:23:21 +0800 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-05-18 00:23:21 +0800 |
| commit | 086c5c9f0239b230d75c8365da0ab365bafaf0c1 (patch) | |
| tree | 43032550fc7c74b337f108f3a53de7e9e5dd9bc7 /utils/Icons.qml | |
| parent | dashboard: fill current tab icon (diff) | |
| download | caelestia-shell-086c5c9f0239b230d75c8365da0ab365bafaf0c1.tar.gz caelestia-shell-086c5c9f0239b230d75c8365da0ab365bafaf0c1.tar.bz2 caelestia-shell-086c5c9f0239b230d75c8365da0ab365bafaf0c1.zip | |
feat: dashboard user
Diffstat (limited to 'utils/Icons.qml')
| -rw-r--r-- | utils/Icons.qml | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/utils/Icons.qml b/utils/Icons.qml index 312ae6d..504cdc5 100644 --- a/utils/Icons.qml +++ b/utils/Icons.qml @@ -151,6 +151,7 @@ Singleton { }) property string osIcon: "" + property string osName function getAppCategoryIcon(name: string, fallback: string): string { const categories = DesktopEntries.applications.values.find(app => app.id === name)?.categories; @@ -187,14 +188,22 @@ Singleton { FileView { path: "/etc/os-release" onLoaded: { - const osId = this.text().split("\n").find(l => l.startsWith("ID="))?.split("=")[1]; + const lines = text().split("\n"); + let osId = lines.find(l => l.startsWith("ID="))?.split("=")[1]; if (root.osIcons.hasOwnProperty(osId)) - return root.osIcon = root.osIcons[osId]; - const osIdLike = this.text().split("\n").find(l => l.startsWith("ID_LIKE="))?.split("=")[1]; - if (osIdLike) - for (const id of osIdLike.split(" ")) - if (root.osIcons.hasOwnProperty(id)) - return root.osIcon = root.osIcons[id]; + root.osIcon = root.osIcons[osId]; + else { + const osIdLike = lines.find(l => l.startsWith("ID_LIKE="))?.split("=")[1]; + if (osIdLike) + for (const id of osIdLike.split(" ")) + if (root.osIcons.hasOwnProperty(id)) + return root.osIcon = root.osIcons[id]; + } + + let nameLine = lines.find(l => l.startsWith("PRETTY_NAME=")); + if (!nameLine) + nameLine = lines.find(l => l.startsWith("NAME=")); + root.osName = nameLine.split("=")[1].slice(1, -1); } } } |