Krolyxon
Commit 3235e63

Branches

Refs →

aurora.configquickshellauroraSetAbout.qml

117 lines · 4.5 KB · QML

1import QtQuick
2import QtQuick.Layouts
3import Quickshell
4import Quickshell.Io
5
6// Settings app > About: what this machine is (one shell probe on open) + live memory / disks from SysStats.
7Flickable {
8 id: flick
9 clip: true
10 contentWidth: width
11 contentHeight: col.implicitHeight
12 boundsBehavior: Flickable.StopAtBounds
13
14 property var info: [] // [[label, value]]
15 function size(v) { return v >= 1000 ? (v / 1024).toFixed(1) + "T" : (v >= 100 ? Math.round(v) : v.toFixed(1)) + "G" }
16
17 Process {
18 running: true
19 command: ["sh", "-c", [
20 '. /etc/os-release 2>/dev/null; printf "system\\t%s\\n" "${PRETTY_NAME:-Linux}"',
21 'printf "kernel\\t%s\\n" "$(uname -r)"',
22 'printf "host\\t%s\\n" "$(cat /etc/hostname 2>/dev/null || uname -n)"',
23 'printf "machine\\t%s\\n" "$(cat /sys/class/dmi/id/product_version 2>/dev/null) ($(cat /sys/class/dmi/id/product_name 2>/dev/null))"',
24 'printf "cpu\\t%s (%s threads)\\n" "$(sed -n "s/^model name[^:]*: //p" /proc/cpuinfo | head -1)" "$(nproc)"',
25 'command -v lspci >/dev/null && lspci | sed -n "s/.*\\(VGA\\|3D\\)[^:]*: //p" | sed "s/ (rev .*//" | while read -r g; do printf "gpu\\t%s\\n" "$g"; done',
26 'printf "hyprland\\t%s\\n" "$(hyprctl version -j 2>/dev/null | sed -n "s/.*\\"tag\\": \\"\\([^\\"]*\\)\\".*/\\1/p")"',
27 'printf "quickshell\\t%s\\n" "$(qs --version 2>/dev/null | head -1 | sed "s/^Quickshell //; s/ (.*//")"',
28 'printf "shell\\t%s\\n" "$(basename "${SHELL:-sh}")"',
29 'command -v pacman >/dev/null && printf "packages\\t%s (pacman)\\n" "$(pacman -Qq | wc -l)"'
30 ].join("; ")]
31 stdout: StdioCollector {
32 onStreamFinished: {
33 var out = [], l = text.split("\n")
34 for (var i = 0; i < l.length; i++) {
35 var t = l[i].indexOf("\t")
36 if (t > 0) out.push([l[i].slice(0, t), l[i].slice(t + 1)])
37 }
38 flick.info = out
39 }
40 }
41 }
42
43 ColumnLayout {
44 id: col
45 width: flick.width
46 spacing: 8
47
48 RowLayout {
49 spacing: 14
50 Text {
51 text: Theme.iArch
52 color: Theme.accent
53 font.family: Theme.font
54 font.pixelSize: 56
55 }
56 ColumnLayout {
57 spacing: 2
58 Text {
59 text: flick.info.length ? flick.info[0][1] : ""
60 color: Theme.fg
61 font.family: Theme.font
62 font.pixelSize: Theme.fontSize + 6
63 font.bold: true
64 }
65 Text {
66 text: Quickshell.env("USER") + "@" + (flick.info.length > 2 ? flick.info[2][1] : "")
67 + " · up " + Theme.fmtTime(SysStats.uptime)
68 color: Theme.dim
69 font.family: Theme.font
70 font.pixelSize: Theme.fontSize
71 }
72 }
73 }
74
75 SectionLabel { text: "system"; Layout.topMargin: 6 }
76 Repeater {
77 model: flick.info
78 delegate: RowLayout {
79 required property var modelData
80 Layout.fillWidth: true
81 spacing: 8
82 Text {
83 Layout.preferredWidth: 150
84 text: modelData[0]
85 color: Theme.accent
86 font.family: Theme.font
87 font.pixelSize: Theme.fontSize
88 }
89 Text {
90 Layout.fillWidth: true
91 text: modelData[1]
92 color: Theme.fg
93 elide: Text.ElideRight
94 font.family: Theme.font
95 font.pixelSize: Theme.fontSize
96 }
97 }
98 }
99
100 SectionLabel { text: "memory & storage"; Layout.topMargin: 6 }
101 StatBar {
102 label: "memory"
103 frac: SysStats.memTotal > 0 ? SysStats.memUsed / SysStats.memTotal : 0
104 valueText: flick.size(SysStats.memUsed) + " / " + flick.size(SysStats.memTotal)
105 }
106 Repeater {
107 model: SysStats.disks
108 delegate: StatBar {
109 required property var modelData
110 label: modelData.label
111 frac: modelData.used / modelData.size
112 fill: frac > 0.9 ? Theme.err : Theme.accent
113 valueText: flick.size(modelData.used) + " / " + flick.size(modelData.size)
114 }
115 }
116 }
117}