summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-08-11 15:14:04 +1000
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-08-11 15:14:04 +1000
commit0771aad11e5302f8829f1e5490bd936963606519 (patch)
tree8791fbade1005dcf6f212e18247a9d903075d84e /utils
parentlock: add resources (diff)
downloadcaelestia-shell-0771aad11e5302f8829f1e5490bd936963606519.tar.gz
caelestia-shell-0771aad11e5302f8829f1e5490bd936963606519.tar.bz2
caelestia-shell-0771aad11e5302f8829f1e5490bd936963606519.zip
lock: add fetch + refactor os info
Diffstat (limited to 'utils')
-rw-r--r--utils/Icons.qml26
-rw-r--r--utils/SysInfo.qml47
2 files changed, 47 insertions, 26 deletions
diff --git a/utils/Icons.qml b/utils/Icons.qml
index cd635a0..2ed9d42 100644
--- a/utils/Icons.qml
+++ b/utils/Icons.qml
@@ -1,7 +1,6 @@
pragma Singleton
import Quickshell
-import Quickshell.Io
import Quickshell.Services.Notifications
Singleton {
@@ -143,9 +142,6 @@ Singleton {
Office: "content_paste"
})
- property string osIcon: ""
- property string osName
-
function getAppIcon(name: string, fallback: string): string {
const icon = DesktopEntries.heuristicLookup(name)?.icon;
if (fallback !== "undefined")
@@ -232,26 +228,4 @@ Singleton {
return "volume_down";
return "volume_mute";
}
-
- FileView {
- path: "/etc/os-release"
- onLoaded: {
- const lines = text().split("\n");
- let osId = lines.find(l => l.startsWith("ID="))?.split("=")[1].replace(/"/g, "");
- if (root.osIcons.hasOwnProperty(osId))
- root.osIcon = root.osIcons[osId];
- else {
- const osIdLike = lines.find(l => l.startsWith("ID_LIKE="))?.split("=")[1].replace(/"/g, "");
- 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].replace(/"/g, "");
- }
- }
}
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<string> 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];
+ }
+ }
+ }
+ }
+ }
+}