Krolyxon
Commit ed7f69d

Branches

Refs →

aurora.configquickshellauroraSetAbout.qml

160 lines · 6.3 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: 22
47
48 // the machine at a glance, like Android's "about phone" header
49 Group {
50 RowLayout {
51 Layout.margins: 14
52 Layout.leftMargin: 22
53 spacing: 18
54 Text {
55 text: Theme.iArch
56 color: Theme.fill
57 font.family: Theme.ui
58 font.pixelSize: 56
59 }
60 ColumnLayout {
61 spacing: 2
62 Text {
63 text: flick.info.length ? flick.info[0][1] : ""
64 color: Theme.fg
65 font.family: Theme.ui
66 font.pixelSize: 21
67 font.bold: true
68 }
69 Text {
70 text: Quickshell.env("USER") + "@" + (flick.info.length > 2 ? flick.info[2][1] : "")
71 + " · up " + Theme.fmtTime(SysStats.uptime)
72 color: Theme.fgDim
73 font.family: Theme.ui
74 font.pixelSize: 15
75 }
76 }
77 }
78 }
79
80 Group {
81 title: "system"
82 keywords: "kernel cpu gpu host hostname distro packages version uptime"
83 gap: 0
84 Repeater {
85 model: flick.info
86 delegate: RowLayout {
87 required property var modelData
88 Layout.fillWidth: true
89 Layout.preferredHeight: 40
90 spacing: 8
91 Text {
92 Layout.preferredWidth: 150
93 Layout.leftMargin: 18
94 text: modelData[0]
95 color: Theme.fill
96 font.family: Theme.ui
97 font.pixelSize: 15
98 }
99 Text {
100 Layout.fillWidth: true
101 Layout.leftMargin: 18
102 text: modelData[1]
103 color: Theme.fg
104 elide: Text.ElideRight
105 font.family: Theme.ui
106 font.pixelSize: 15
107 }
108 }
109 }
110 }
111
112 Group {
113 title: "memory & storage"
114 keywords: "ram disk space drives usage"
115 gap: 14
116 StatBar {
117 Layout.leftMargin: 18
118 Layout.rightMargin: 18
119 Layout.topMargin: 12
120 label: "memory"
121 frac: SysStats.memTotal > 0 ? SysStats.memUsed / SysStats.memTotal : 0
122 valueText: flick.size(SysStats.memUsed) + " / " + flick.size(SysStats.memTotal)
123 }
124 Repeater {
125 model: SysStats.disks
126 delegate: StatBar {
127 required property var modelData
128 Layout.leftMargin: 18
129 Layout.rightMargin: 18
130 label: modelData.label
131 frac: modelData.used / modelData.size
132 fill: frac > 0.9 ? Theme.err : Theme.fill
133 valueText: flick.size(modelData.used) + " / " + flick.size(modelData.size)
134 }
135 }
136 Item { Layout.preferredHeight: 2 }
137 }
138
139 Group {
140 title: "credits"
141 keywords: "license glyph-rice fonts"
142 Text {
143 Layout.fillWidth: true
144 Layout.leftMargin: 18
145 Layout.rightMargin: 18
146 Layout.topMargin: 10
147 Layout.bottomMargin: 10
148 wrapMode: Text.WordWrap
149 lineHeight: 1.3
150 color: Theme.fgDim
151 font.family: Theme.ui
152 font.pixelSize: 14
153 text: "The dot-matrix shaders and some components started as ports from glyph-rice by Nebelung-cloud "
154 + "(GPL-3.0). Fonts: Doto, Space Grotesk, Space Mono (SIL OFL). Colours: matugen (Material You). Nothing, Nothing OS and Glyph are trademarks of Nothing Technology Ltd; "
155 + "this is a fan project, not affiliated with Nothing."
156 }
157 }
158
159 }
160}