From 0771aad11e5302f8829f1e5490bd936963606519 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Mon, 11 Aug 2025 15:14:04 +1000 Subject: lock: add fetch + refactor os info --- utils/SysInfo.qml | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 utils/SysInfo.qml (limited to 'utils/SysInfo.qml') diff --git a/utils/SysInfo.qml b/utils/SysInfo.qml new file mode 100644 index 0000000..968dc52 --- /dev/null +++ b/utils/SysInfo.qml @@ -0,0 +1,47 @@ +pragma Singleton + +import Quickshell +import Quickshell.Io + +Singleton { + id: root + + property string osName + property string osPrettyName + property string osId + property list osIdLike + property string logo + property string osIcon: "" + + readonly property string user: Quickshell.env("USER") + readonly property string wm: Quickshell.env("XDG_CURRENT_DESKTOP") || Quickshell.env("XDG_SESSION_DESKTOP") + readonly property string shell: Quickshell.env("SHELL").split("/").pop() + + FileView { + id: osRelease + + path: "/etc/os-release" + onLoaded: { + const lines = text().split("\n"); + + const fd = key => lines.find(l => l.startsWith(`${key}=`))?.split("=")[1].replace(/"/g, "") ?? ""; + + root.osName = fd("NAME"); + root.osPrettyName = fd("PRETTY_NAME"); + root.osId = fd("ID"); + root.osIdLike = fd("ID_LIKE").split(" "); + root.logo = fd("LOGO"); + + const osIcons = Icons.osIcons; + if (osIcons.hasOwnProperty(root.osId)) { + root.osIcon = osIcons[root.osId]; + } else { + for (const id of root.osIdLike) { + if (osIcons.hasOwnProperty(id)) { + root.osIcon = osIcons[id]; + } + } + } + } + } +} -- cgit v1.2.3-freya